Docker CMD

From ElectroDragon Wiki
Revision as of 21:42, 28 May 2020 by Chao (talk | contribs) (Created page with "== Commands == === Container === * docker ps -a * docker kill * docker rm <CONTAINER ID> ==== Docker exec - Enter into container ==== * docker exec -it nginx /bin/bash # i no...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Commands

Container

  • 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

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

Examples

  • 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

working

  • 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 <info@electrodragon.com>" \
   --message "修改了默认网页" \
   webserver \
   nginx:v2
  • 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 这个镜像标记为 127.0.0.1:5000/ubuntu:latest。
Docker tag ubuntu:latest hechaodo/test1
  • Push
Docker push hechaodo/test1