Docker进入容器的方法

By | 2019 年 12 月 30 日

推荐:使用docker exec进入Docker容器

$ sudo docker exec --help   
Usage:  docker exec [OPTIONS] CONTAINER COMMAND [ARG...]
Run a command in a running container
Options:
  -d, --detach               Detached mode: run command in the background
      --detach-keys string   Override the key sequence for detaching a container
  -e, --env list             Set environment variables
  -i, --interactive          Keep STDIN open even if not attached
      --privileged           Give extended privileges to the command
  -t, --tty                  Allocate a pseudo-TTY
  -u, --user string          Username or UID (format: <name|uid>[:<group|gid>])
  -w, --workdir string       Working directory inside the container

所以进入一个运行的容器:

sudo docker ps  
sudo docker exec -it 775c7c9ee1e1 /bin/bash  

发表回复

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据