Image Build & Push Container Run & Manage
Docker
Command What does it do? Command What does it do?
docker build -t myapp :1.0 . To build an image from the Docker file and tag it To run a container from defined image
use -d to run container in background
docker image ls To list all the images that are locally stored:
use -p to publish port to container
Cheat Sheet docker rmi <name>
docker tag <name>
<repo-url>/<name>
To delete an image from the Docker Store
To tag an image with repo url or username and image
name
docker run <image-name>
use --name to name the container
use -e to pass env variable in container
use --restart to define restart behaviour
To list the running container
docker push <repo-url>/<name> To push the docker image to repository docker ps
use -a to see all container
docker stop <container-id> To stop a running container
Docker Volume
docker rm <container-id> To remove a container in exited mode
Command What does it do?
docker exec -it <container-id>
To execute command inside container interactive shell
docker volume <name> To create a docker volume <command>
Use -v flag followed volume name and mount path to docker inspect <container-id> To list information of a container
docker run -v
mount a volume in container
To retrieve logs of application inside the container
Ex: OR docker log <container-id>
use -f to retrieve logs in streaming mode
docker run -v vol:/data redis Use -v flag followed host path and mount path to mount
docker run -v $PWD:/data redis a volume in container docker top <container-id> To retrieve resource utilization of a container
docker volume inspect docker commit
To list information of a volume To create an image from a container
<volume-name> <container-name>
Clean-up Docker Network
Command What does it do? Command What does it do?
docker system prune To remove all containers, images, network and volumes To create new network
docker network create
use --type to define the driver type
docker stop $(docker ps -q -a) To stop all running containers
docker run --net
docker rm $(docker ps -q -a) To remove all exited containers
Use -v flag to run container in network of your choice
docker rmi $(docker image ls) To remove all local images Ex:
docker run --net mynetwork
docker network inspect
To list information of a network
<network-name>
Online Interactive Training on AWS | Azure | Google Cloud | DevOps
https://webmagicinformatica.com