Docker Commands
Docker Commands
com
https://container.training/
DCA: https://github.com/Evalle/DCA
DCA: https://medium.com/bb-tutorials-and-thoughts/250-practice-questions-for-the-
dca-exam-84f3b9e8f5ce
-------------------
Docker Introduction
-------------------
https://www.linuxjournal.com/content/docker-lightweight-linux-containers-
consistent-development-and-deployment
https://blog.jayway.com/2015/03/21/a-not-very-short-introduction-to-docker/
------------
Installation
------------
https://learnk8s.io/installing-docker-kubernetes-windows
(or)
$ systemctl enable --now docker
---------------
Basic commands
---------------
List of commands: https://docs.docker.com/engine/reference/commandline/docker/
docker --help
docker version
docker -v
docker info
docker events
docker system df
docker system prune
-------------
Docker images
-------------
Official Images: https://github.com/docker-library/official-images (or)
https://github.com/docker-library/docs (or)
https://github.com/docker-library/docs/tree/master/python
By default, you are prompted to continue. To bypass the prompt, use the -f or --
force flag.
You can limit which images are pruned using filtering expressions with the --filter
flag.
For example, to only consider images created more than 24 hours ago:
-----------------
Docker containers
-----------------
https://container.training/intro-selfpaced.yml.html#103
https://rakeshjain-devops.medium.com/elucidating-containers-and-container-runtimes-
b4897b45b377
Example images:
hello world(tutum)
jpetazzo/clock
Jenkins, Nexus3, Ubuntu, Nginx
docker container run --publish 80:80 --name webhost nginx -> creates a container
with name as webhost
docker run --rm --name c1 alpine echo hello
docker run --restart=always --rm --name c1 alpine echo hello -> WONT WORK
docker container start < unique container id> -> start a stopped container
docker container stop <unique container id> -> stops container
docker container stop $(docker ps -a -q) -> Stops all containers
docker container kill <unique container id> -> force kill a non-responding
container
----------- STOP vs KILL
docker stop attempts to gracefully shutdown container(s) by issuing a SIGTERM
signal(kill -15) to the main process inside the container
docker kill (by default) immediately stops/terminates them by issuing a (kill -9)
signal to the main process
With docker stop, the container(s) must comply to the shutdown request within a
(configurable) grace period (which defaults to 10 seconds),
after which it forcibly tries to kill the container. docker kill does not have any
such timeout period.
-------------
docker container logs <container name> -> displays logs in static mode
docker container logs -f <container name> -> displays logs in follow/live mode
docker container rm <container 1> <container 2 -> remove docker containers; doesn’t
remove running containers
docker container rm -f <container 1> -> Force remove running containers
docker container rm -f $(docker ps -a -q) -> Removes all containers; -q is quiet
mode that displays only numeric IDs of containers
docker rm $(docker ps -a -q -f status=exited)
docker container inspect <container> -> gives the config and meta data used to
start this container; returns JSON array
docker container stats <container> -> gives live info on CPU, Memory usage, I/O of
the container
docker stats -> gives live info on CPU, Memory usage, I/O of all the containers
docker diff <container> -> List the changed files and directories in a container᾿s
filesystem since the container was created.
Three different types of change are tracked:
A = file or directory was added
D = file or directory was deleted
C = file or directory was changed
docker export <container> -o file.tar -> export file system contents of a container
as a tarball
docker export <container> > file.tar
docker import file.tar -> This creates a new untagged image
docker events -> Use docker events to get real-time events from the server.
docker run -d -it --name c1 ubuntu sleep 300
docker stop c1
docker kill c1
kill <PID>
kill -9 <PID>
---------------
Docker Registry
---------------
registry:2
https://docs.docker.com/registry/deploying/
https://docs.docker.com/registry/spec/api/
https://www.exoscale.com/syslog/setup-private-docker-registry/
Once you login, a auth token will be saved under ~/.docker/config.json in user's
home directory
It is username:password base64 encoded
cat $HOME/.docker/config.json
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "ergsffgG35gsjqyxofbkfdyu7s223l0MThA"
}
}
}
Docker expects a secured channel by default, and that’s naturally a very good
thing.
Configuring Docker to accept connections to unsecure registries depends on your OS,
but it’s quite straightforward.
{
"insecure-registries" : ["Repo-URL"]
}
On macOS you do it using the user interface, and the changes will automatically
restart the daemon:
--------
AWS CLI
--------
https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-mac.html
https://docs.aws.amazon.com/cli/latest/userguide/
https://docs.aws.amazon.com/cli/latest/userguide/welcome-examples.html
aws --version
aws configure
--------
AWS ECR
--------
https://aws.amazon.com/ecr/
https://aws.amazon.com/ecr/resources/
https://docs.aws.amazon.com/AmazonECR/latest/userguide/what-is-ecr.html
https://docs.aws.amazon.com/AmazonECR/latest/userguide/get-set-up-for-amazon-
ecr.html
https://docs.aws.amazon.com/AmazonECR/latest/userguide/getting-started-cli.html
aws configure
aws ecr create-repository --repository-name nginx --image-scanning-configuration
scanOnPush=true --region ap-south-1
docker tag nginx:latest 185558408682.dkr.ecr.ap-south-1.amazonaws.com/nginx:latest
aws ecr get-login-password --region ap-south-1 | docker login --username AWS --
password-stdin 185558408682.dkr.ecr.ap-south-1.amazonaws.com
docker push 185558408682.dkr.ecr.ap-south-1.amazonaws.com/nginx
aws ecr batch-delete-image --repository-name nginx --image-ids imageTag=latest
aws ecr batch-delete-image --repository-name nginx --image-ids imageTag=v1
--------
AWS ECS
--------
https://tutorialsdojo.com/amazon-elastic-container-service-amazon-ecs/
https://www.section.io/engineering-education/using-ecs-to-deploy-docker-app-to-aws/
------------
AWS Fargate
------------
https://www.janbasktraining.com/blog/what-is-aws-fargate/
-------------
docker volume
-------------
https://docs.docker.com/storage/
https://www.baeldung.com/ops/docker-volumes
https://www.section.io/engineering-education/sharing-data-between-docker-
containers/
docker volume ls
docker volume create test
docker volume inspect test
docker volume rm test
docker volume prune
--volumes-from
Bind:
docker run -d --name web -p 80:80 -v
$PWD/index.html:/usr/share/nginx/html/index.html nginx
docker run -d --name web -p 80:80 -v $PWD/nginx-data:/usr/share/nginx/html nginx
Named:
docker run -d --name web -p 80:80 -v nginx-data:/usr/share/nginx/html nginx
docker run -d -p 8080:8080 -p 50000:50000 -v jenkins-backup:/var/jenkins_home
jenkins/jenkins:lts
docker run -d \
--name devtest \
--mount source=myvol2,target=/app \
nginx:latest
Shared volumes:
docker run -it --name C1 -v my_vol:/tmp ubuntu
root@475bs990:/# echo "Hello" > /tmp/test.log
root@ 475bs990:/# exit
---------------------
Environment Variables
---------------------
https://vsupalov.com/docker-arg-env-variable-guide/
https://docs.docker.com/engine/swarm/secrets/
SYSTEM ENV
Take environment values from a file (env_file): docker run --env-file my-env.txt
alpine:3 env
Pass environment variable values from your host: docker run -e env_var_name alpine
env
DB-CONNECTOR:
---------------
docker networks
---------------
https://docs.docker.com/network/
https://docs.docker.com/config/containers/container-networking/
https://docs.docker.com/network/links/
https://www.aquasec.com/cloud-native-academy/docker-container/docker-networking/
https://stackoverflow.com/questions/41768157/how-to-link-containers-in-docker
https://dev.vividbreeze.com/docker-networking-bridge-network/
https://foxutech.com/docker-bridge-networking/
https://runnable.com/docker/basic-docker-networking
https://www.section.io/engineering-education/understanding-docker-networking/
https://upcloud.com/community/tutorials/wordpress-with-docker/
https://www.linkedin.com/pulse/poor-mans-load-balancing-docker-luis-herrera
https://medium.com/patrik-bego/docker-networking-practical-examples-23900904486e
--links
docker container run -d --name web2 nginx:alpine
docker container run -d --name web1 --link web2:web2 nginx:alpine
docker exec -it web1 bash
root@fd4ec3dc07b3:/# ping web2
--net-alias or –-network-alias
docker network create my_net -> creates a bridge network
docker container run -d --net my_net --net-alias search elasticsearch:2
docker container run -d --net my_net --net-alias search elasticsearch:2
docker container run --rm --net my_net alpine nslookup search
----------------------
Load Balancing
----------------------
https://superuser.openstack.org/articles/run-load-balanced-service-docker-
containers-openstackmic
Change the config file /etc/nginx/conf.d/default.conf and add the below content.
#IPs represent the EC2 public IP
upstream backends {
server hello1:80;
server hello2:80;
server hello3:80;
# This server accepts all traffic to the port 80 and passes it to the upstream.
# Notice that the upstream name and the proxy_pass need to match.
server {
listen 80;
location / {
proxy_pass http://backends;
}
}
HA Proxy: https://www.haproxy.com/blog/haproxy-configuration-basics-load-balance-
your-servers/; https://hub.docker.com/r/haproxytech/haproxy-ubuntu
https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-
interact
https://docs.docker.com/language/
https://github.com/docker-library/official-images
https://docs.docker.com/engine/reference/builder/
https://docs.docker.com/develop/develop-images/dockerfile_best-practices/
https://learnk8s.io/blog/smaller-docker-images
https://adotpalindrome.wordpress.com/2020/02/25/three-ways-to-create-docker-images-
for-java/
http://tutorials.jenkov.com/docker/dockerfile.html
https://vsupalov.com/docker-arg-env-variable-guide/
https://codefresh.io/docker-tutorial/not-ignore-dockerignore-2/
https://sysdig.com/blog/dockerfile-best-practices/
https://cloud.google.com/architecture/best-practices-for-building-containers
https://docs.microsoft.com/en-us/visualstudio/docker/tutorials/docker-tutorial
https://developer.cisco.com/docs/iox/#!tutorial-build-sample-docker-type-python-
simple-app/tutorial-build-sample-docker-type-python-simple-app
https://www.section.io/engineering-education/how-to-containerize-a-python-
application/
https://scoutapm.com/blog/how-to-use-docker-healthcheck
https://www.indellient.com/blog/how-to-dockerize-an-angular-application-with-nginx/
https://github.com/heroku/node-js-getting-started
https://wkrzywiec.medium.com/build-and-run-angular-application-in-a-docker-
container-b65dbbc50be8
https://gobyexample.com/hello-world
https://www.askpython.com/python/environment-variables-in-python
https://github.com/wkrzywiec/aston-villa-app.git
************
Example-01:
************
FROM alpine/git as CLONE
WORKDIR /app
RUN git clone https://github.com/kunchalavikram1427/simple-html-page.git .
FROM nginx:stable-alpine
COPY --from=CLONE /app/index.html /usr/share/nginx/html/index.html
************
Example-02:
************
FROM alpine/git as CLONE
WORKDIR /app
RUN git clone https://github.com/wkrzywiec/aston-villa-app.git .
https://blog.mayadata.io/openebs/steps-to-deploy-angular-application-on-kubernetes
Nodejs multistage: https://morioh.com/p/4eb4646c371d
https://codefresh.io/docker-tutorial/create-docker-images-for-java/
https://adotpalindrome.wordpress.com/2020/02/25/three-ways-to-create-docker-images-
for-java/
https://acloudxpert.com/install-maven-on-amazon-linux-rhel/
https://cloud.google.com/blog/products/containers-kubernetes/kubernetes-best-
practices-how-and-why-to-build-small-container-images
https://docs.docker.com/develop/develop-images/multistage-build/
https://www.ardanlabs.com/blog/2020/02/docker-images-part1-reducing-image-size.html
https://tiangolo.medium.com/react-in-docker-with-nginx-built-with-multi-stage-
docker-builds-including-testing-8cc49d6ec305
https://github.com/tiangolo/blog-posts/tree/master/react-in-docker
https://learnk8s.io/developing-and-packaging-nodejs-docker
https://learnk8s.io/spring-boot-kubernetes-guide
Custom Nginx:
FROM nginx
COPY index.html /usr/share/nginx/html/index.html
FROM,ARG,ENV,LABEL,MAINTAINER,WORKDIR,VOLUME,RUN,ADD,COPY,EXPOSE,CMD,ENTRYPOINT,HEA
LTHCHECK,ONBUILD
Shell form:
CMD sleep 10
JSON/Executable form:
CMD ["sleep", "10"]]
VOLUME /app/nginx
docker run -d -v nginx_data:/app/nginx nginx
FROM python
CMD ["--version"]
ENTRYPOINT ["python3"]
FROM ubuntu:trusty
CMD ["localhost"]
ENTRYPOINT ["ping"]
import os
home_dir =os.environ['HOME']
username = os.environ['USER']
print(f'{username} home directory is {home_dir}')
Health Status: docker container inspect --format '{{ .State.Health.Status }}' web
--------------------------
Dockerfile Best Practices
--------------------------
https://www.docker.com/blog/intro-guide-to-dockerfile-best-practices/
--------------------------
Container Runtime Security
--------------------------
https://snyk.io/learn/container-security/runtime-security/
--------------------------
Multistage builds
--------------------------
https://www.docker.com/blog/intro-guide-to-dockerfile-best-practices/
-----------------------
Distroless & Ephemeral
-----------------------
https://learnk8s.io/blog/smaller-docker-images
https://github.com/learnk8s/learnk8s.io/blob/master/src/smallerDockerImages/
content.md
https://medium.com/@luke_perry_dev/dockerizing-with-distroless-f3b84ae10f3a
https://www.abhaybhargav.com/stories-of-my-experiments-with-distroless-containers/
https://learnk8s.io/blog/smaller-docker-images
https://www.infracloud.io/blogs/secure-containers-cosign-distroless-images/
https://www.thoughtworks.com/radar/techniques/distroless-docker-images
https://hackernoon.com/why-its-important-to-keep-your-containers-small-and-simple-
618ced7343a5
https://towardsdatascience.com/the-easiest-way-to-debug-kubernetes-workloads-
ff2ff5e3cc75
https://nigelpoulton.com/kubernetes-ephemeral-containers/
https://minikube.sigs.k8s.io/docs/handbook/config/#enabling-feature-gates
https://medium.com/01001101/ephemeral-containers-the-future-of-kubernetes-workload-
debugging-c5b7ded3019f
--------------------
docker compose
--------------------
https://docs.docker.com/compose/networking/
https://vsupalov.com/docker-arg-env-variable-guide/
https://takacsmark.com/docker-compose-tutorial-beginners-by-example-basics/
https://github.com/kunchalavikram1427/voting-app
https://github.com/dockersamples/example-voting-app
.env file-> a file with key value pairs used to put values into the docker-
compose.yml & docker stack file which is in the same folder.
It’s exclusively a docker-compose.yml thing.
.env
VARIABLE_NAME=some value
OTHER_VARIABLE_NAME=some other value, like 5
USAGE:
version: '3'
services:
plex:
image: linuxserver/plex
environment:
- env_var_name=${VARIABLE_NAME} # here it is
web02:
build:
context: ./java
dockerfile: my-dockerfile
args:
- repo: my-repo
- build: 01
image: web02
container_name:
hostname:
environment:
- HOME=/home
volumes:
- "vol-01:/var/lib/"
networks:
- front-end
ports:
- 80:80
volumes:
vol-01
networks:
front-end
back-end
.env file:
PYTHON_VERSION=3.7.0-alpine3.8
REDIS_VERSION=4.0.11-alpine
DOCKER_USER=admin
version: "3"
services:
app:
build:
context: .
args:
- IMAGE_VERSION=${PYTHON_VERSION}
image: ${DOCKER_USER}/flask-redis:1.0
env_file: .env.txt
ports:
- 80:5000
networks:
- mynet
redis:
image: redis:${REDIS_VERSION}
networks:
- mynet
volumes:
- mydata:/data
networks:
mynet:
volumes:
mydata:
-------------------------
Advanced Docker Commands
-------------------------
Tar and untar a image:
docker save image_name:tag > file_name.tar
docker load < file_name.tar
--------------
docker-swarm
--------------
https://docs.docker.com/engine/swarm/
https://docs.docker.com/engine/swarm/swarm-tutorial/
https://docs.docker.com/engine/swarm/swarm-tutorial/#open-protocols-and-ports-
between-the-hosts
https://github.com/jpetazzo/container.training/blob/main/slides/swarm/
healthchecks.md
https://hub.docker.com/r/dockersamples/visualizer
https://docs.docker.com/engine/swarm/raft/
https://docs.docker.com/engine/swarm/services/#placement-constraints
https://thenewstack.io/methods-dealing-container-storage/
https://theworkaround.com/2019/05/15/docker-swarm-persistent-storage.html
yum update && yum install docker -y && systemctl enable --now docker
#! /bin/bash
sudo yum update -y
sudo yum install docker
sudo usermod -aG docker ec2-user
sudo systemctl enable --now docker
docker service ls
docker service ps <service-name>
docker node ps
docker node ps <node-name>
docker node inspect self or master1 or worker1
docker node promote - Promote one or more nodes to manager in the swarm
docker node demote - Demote one or more nodes from manager in the swarm
-----------------
overlay networks
-----------------
docker network create -d overlay my_overlay
docker network create --subnet 10.1.0.0/24 --gateway 10.1.0.1 -d overlay mynet ->
Create an overlay network and specify a subnet
docker service create --name psql --network my_overlay -e POSTGRES_PASSWORD=pass
postgres
docker service create --name drupal --network my_overlay -p 80:80 drupal
--------------------
docker stack deploy
--------------------
docker stack deploy -c <docker-compose.yml> <stack-name>
docker stack ls
docker stack ps <stack-name>
docker service ls
docker stack rm <stack-name>
version: '3.3'
services:
wordpress:
image: wordpress
depends_on:
- mysql
ports:
- 80:80
deploy:
replicas: 1
restart_policy:
condition: on-failure
placement:
constraints:
- node.role == manager
environment:
WORDPRESS_DB_HOST: mysql
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
volumes:
- wordpress-data:/var/www/html
networks:
- my_net
mysql:
image: mariadb
deploy:
replicas: 1
restart_policy:
condition: on-failure
placement:
constraints:
- node.role == worker
environment:
MYSQL_ROOT_PASSWORD: wordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
volumes:
- mysql-data:/var/lib/mysql
networks:
- my_net
networks:
my_net:
volumes:
mysql-data:
wordpress-data:
---------------------
Best vs Bad practices for Dockerfile
---------------------
---------------------
Sample HTML Page
---------------------
<!DOCTYPE html>
<html>
<head>
<title>Welcome to custom nginx!</title>
</head>
<body>
<h1>Welcome to custom nginx!</h1>
<p> Hello World!!!</p>
</body>
</html>
---
<html>
<img
src="https://upload.wikimedia.org/wikipedia/commons/4/45/A_small_cup_of_coffee.JPG"
alt="A Cup Coffee">
</html>
---
<!DOCTYPE html>
<html>
<head>
<title>Hello World</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Hello World</h1>
<p>Nice to meet you!</p>
<p><em>Thanks for stopping by...</em></p>
</body>
</html>
------------------------------------
Docker task:
https://github.com/dubareddy/docker_k8s_task
Some time, we need to change the docker root directory if we are running out of
disk space.
data present by default under /var/lib/docker can be changed to the path since the
disk is full (new path: /backup/docker)
Take backup of the current directory using tar -zcvf docker-backup-$(date +
%s).tar.gz /var/lib/docker
systemctl stop docker
Create a directory "/backup" to set a new path: mkdir /backup
rsync -avzh /var/lib/docker /backup
lets update systemd with new location
vi /lib/systemd/system/docker-service
under [Service], do not remove any options on that line just add below option
{
"data-root": "/backup-docker",
...
...
}
save and exit. Now restart docker service, no need to reload systemd service.
systemctl daemon-reload
systemctl start docker
Change the default docker0 bridge to any other bridge network for containers
created.
Connect Docker host (daemon) from remote server (docker client).
Investigate on --link option.
Build your own custom image for nginx with below options covered in your
Dockerfile: FROM RUN MAINTAINER COPY ADD ENTRYPOINT CMD ARG ENV HEALTHCHECK EXPOSE
VOLUME
Intigrate NFS storage to backend volume mount in Docker
Use disk (Example: /dev/sdb) as backend storage for volume mount.
Deploy local-registry with TLS (443) certs.
Deploy web application (Wordpress) and DB (MariaDB). We need to create a simple web
site with the wordpress from browser and verify that details are stored in
wordpress DB.
Deploy Jenkins CICD with custom parameters mentioned below: Jenkins should have
docker and kubernetes plugin installed as a prerequesit.(Should not be done through
jenkins dashboard) --> Dockerfile Setup jenkins with skipWizard and we should login
with our username and password defined in Dockerfile. So that I can login to
dashboard directly when I access URL.
----------------------------
Setup Java & Maven
----------------------------
Java-8:
Java-11:
Maven:
cd /opt
sudo curl -O https://dlcdn.apache.org/maven/maven-3/3.8.4/binaries/apache-maven-
3.8.4-bin.tar.gz
sudo tar -xvzf apache-maven-3.8.4-bin.tar.gz
echo "export M2_HOME="/opt/apache-maven-3.8.4"" >> ~/.bashrc
echo "export PATH="$PATH:/opt/apache-maven-3.8.4/bin"" >> ~/.bashrc
source ~/.bashrc
mvn -version