Docker CMD

From ElectroDragon Wiki



  • docker ps -a
  • docker kill
  • docker rm <CONTAINER ID>

Docker exec - Enter into container

  • docker exec -it nginx /bin/bash # i no interrupt, t terminal
  • quit by Ctrl-p Ctrl-q.

Docker Images


  • list -> docker images
  • delete -> stop container first -> docker rm -f <CONTAINER ID> -> del images -> docker rmi images_ID
  • delete multiple -> docker rmi dd025cdfe837 9032a2781408

Docker run


  • docker run --rm -it -v //c/Users/electrodragon/nodemcu-firmware:/opt/nodemcu-firmware marcelstoer/nodemcu-build
  • docker run -it ubuntu bash
  • docker run -d -p 80:80 --name webserver nginx
  • search centos images:
$ docker search centos #search
$ docker pull centos #download pure centos

run & commands

  • docker run -it -v $PWD/:/var wyveo/nginx-php-fpm:latest bash
  • docker run -it -d -p 80:80 --name=ppp -v $PWD/:/var ttt bash
  • docker run -it ttt bash


  • docker run -d -p 80:80 --name=kod -v $PWD/:/usr/share/nginx/html/ ttt

Not working in this way

  • docker run -it -d -p 80:80 --name=ppp -v $PWD/:/usr/share/nginx/html/ ttt3 bash

Docker Exec

Docker CP

  • 实例:将主机/www/runoob目录拷贝到容器96f7f14e99ab的/www目录下。
  • docker cp /www/runoob 96f7f14e99ab:/www/

Exec into docker

  • docker exec -it the_name bash

Commit and push

Eample: ubuntu with apt-get update

  • check the differences - docker diff webserver
  • Commit
docker commit \
   --author "Electrodragon <>" \
   --message "修改了默认网页" \
   webserver \
  • run image nginx:v2
docker run --name web2 -d -p 81:80 nginx:v2
similar: docker run  --name test1 -it ubuntu:latest bash

Login and push

  • Docker login
  • Tag 使用 docker tag 将 ubuntu:latest 这个镜像标记为。
Docker tag ubuntu:latest hechaodo/test1
  • Push
Docker push hechaodo/test1