Categories
Tags
334 words
2 minutes
Essential Docker Commands
Most essential docker commands that helps every DevOps people.
Docker makes it easy to package and run applications in any environment by using containers. Knowing a few essential Docker commands can help you create, manage, and troubleshoot these containers effortlessly. In this guide, we’ll cover the must-know commands to get you started with Docker quickly and efficiently. Let’s dive in!
docker build -t my-app .
- Build a docker imagedocker run -dit -p 80:80 my-app
- Run a container in detached mode in port 80docker ps
- List all the running containersdocker logs my-app
- View logs of a specific containerdocker exec -it my-app /bin/bash
- Access container shelldocker push my-app:latest
- Upload image to docker registrydocker pull my-app:latest
- Download image from docker registrydocker system prune
- Delete unused containers, images, and volumesdocker volume create my-volume
- Create a persistent volume on hostdocker volume ls
- List all persistent volumesdocker network create my-network
- Create a custom network on hostdocker volume ls
- List all the networks created and configureddocker network connect my-network my-app
- Connects the container to the custom networkdocker-compose up -d
- Run the compose file that contains multi-container configurationsdocker-compose down
- Stop the compose file that contains multi-container configurationsdocker inspect my-app
- View the container detailsdocker image history my-app
- View the docker image build historydocker stats
- Monitor container resource utilization on host leveldocker diff my-app
- See changes made in a containerdocker cp my-app:/file/path/within/container /host/path/target
- Copy files from container to host machinedocker update --restart=always my-app
- Update container to auto-restart on whenever it stopsdocker tag my-app:v1 my-app:v2
- Rename the docker image and it’s versiondocker login my-registry.azurecr.io
- Manually authenticate the Azure container registrydocker run --rm -it my-app /bin/bash
- Run a container and remove it on exitdocker run --name my-db -e POSTGRES_PASSWORD=mysecretpassword -d postgres
- Run a container with environment variables
ConclusionThis is it! You’ve learnt the basic essential docker commands. If you have any doubts/issues/errors with the above contents,
feel free to contact me
. Cheers, Happy learning.