Docker Study Note

Yst@IT
3 min readMar 18, 2020

This post is mainly for my own study reference. Clap for me if you find it useful too!

  • docker info
  • docker rm $(docker ps -aq)
  • docker rm -f $(docker ps -aq)
  • docker rmi $(docker images -aq)
  • docker run -d --name nginx1 nginx
  • docker run -d --name nginx -p 80:80 nginx
  • docker diff nginx
  • docker container inspect -f “{{json .NetworkSettings.Networks.bridge.IPAddress}}” nginx
  • docker container inspect -f “{{json .NetworkSettings.Networks.bridge}}” nginx | python -m json.tool
  • docker inspect/start/stop/rm/kill nginx
  • docker container/image/system/network prune
  • docker run -itd --name php php
  • docker run -itd --name alpine alpine
  • docker attach alpine
  • docker rename alpine newalpine
  • docker exec alpine ls
  • docker run --name alpine1 alpine ls
  • docker run -it --name alpine2 alpine ls
  • docker run -it --name alpine3 alpine /bin/sh
  • docker ps -a / docker container ls -a
  • docker ps / docker container ls
  • docker diff nginx
  • docker commit alpine alpine:v1
  • docker tag <image_id> alpine:v1
  • docker build -t hello:v1 .
  • docker push hello:v1
  • docker ps -af status=exited/running
  • docker image history alpine
  • docker image inspect — format “{{json .RootFS}}” alpine | python -m json.tool
  • docker search centos
  • docker run -dP -e Key=”value” --name webserver nginx
  • docker exec webserver env
  • docker port webserver
  • docker run -d --name webserver1 -p 80:80 -v volume:/var/www/html php:7.2-apache
  • volume is located at /var/lib/docker/volumes/
  • docker plugin install vieux/sshfs --grant-all-permissions
  • docker plugin ls
  • docker create/inspect volume
  • docker create network mynet
  • docker network ls
  • docker create --name myweb --network mynet -p 80:80 nginx
  • docker start myweb
  • docker run -d --name myweb1--network mynet -P nginx
  • docker network connect/disconnect mynet centos
  • docker run -itd --name mycentos --network mynet centos
  • docker create network -d overlay mynet
  • docker run -d --name myweb --network host nginx
  • for host network, -p is ignore since container will use host server network. Port used by service running in container will map directly to host server port
  • inspect network to see what containers are connected to the network
  • docker swarm init
  • docker swarm join --token SWXXXXX 172.31.4.84:2377
  • docker swarm join-token manager
  • docker node ls
  • docker service create --replicas 3 -p 80:80 --name myswarm nginx
  • docker service inspect --pretty myswarm
  • docker service ls
  • docker service scale myswarm=5
  • docker node ps
  • docker service rm myswarm
  • docker node update --availability drain manager
  • docker node promote worker_node
  • docker node rm node_name
  • docker swarm leave

--

--

Yst@IT

Cloud Solution Architect, focusing on Oracle Cloud Infrastructure currently.