深度阅读

How to SSH into a running Docker Container in different ways

作者
作者
2023年08月22日
更新时间
8.04 分钟
阅读时间
0
阅读量

Docker is used to creating containers. In this tutorial, we examine how to SSH into a running Docker Container in different ways like using the docker exec , docker attach command.

Using “docker exec”

Different commands can be run by using the “docker exec” as well as the bash can be also started. A container can be started by using the “docker run” command .

$ sudo docker run --name myubuntu -d ubuntu

Then we should list the running container name.

$ sudo docker ps

The syntax of the “docker exec” command to run bash shell is .

$ sudo docker exec -it ubuntu /bin/bash

Using “docker attach”

Another way to SSH into the running docker container is using the “docker attach .

$ sudo docker attach myubuntu

博客作者

热爱技术,乐于分享,持续学习。专注于Web开发、系统架构设计和人工智能领域。