Docker is a very versatile framework. You need to be familiar with all of its capabilities to get the most of it. This will be easier if you know about the different docker commands that are available to you. We compiled a list of 33 of the most important docker commands.
Commands for Managing your Docker Images and Containers:
Here is a small list of important docker commands that make it a lot easier to work with images and docker containers. They work well with tools like JFrog.
Docker compose
The docker compose command is used to define and run docker applications with multiple containers. It will do this by raising the machine with a docker-compose file. You must enter the folder where the file is located.
docker pull NAME NAME
This command is used to download an image from the docker.
docker images
This command is useful when you need to show images we have downloaded from docker.
docker ps -a
This command shows which containers are working in a docker at any given time.
docker rmi IMAGE_ID
docker info
This command displays information about the image associated with the ID. This information includes its size, creation date and its name.
docker search NAME
This command is used to search for a string or file name in a docker container.
docker logs <friendly-name|container-id>
This command is used to retrieve batches of logs from a docker. It is a useful command, but can only used within containers that begin with either the journald or json-file drivers.
docker start
This command is used to start docker containers. You can use the command to start multiple containers if you choose.
docker stop
This command is used to end docker containers. You can use the command to end multiple containers if you choose.
docker kill
This command is used to kill docker containers. You can use the command to kill multiple containers if you choose.
docker rm
This command is used to destroy any container IDs that have been retrieved and passed with the ps -a -q docker command.
docker build –build-arg -t <image_name>
This command is used to build an image with docker.
docker build –build-arg http_proxy=http://<proxy>:<port> –build-arg https_proxy=http://<proxy>:<port> -t <image_name>
This command is used to build an image behind a proxy.
docker pull nginx:1.13-alpine
This command is used to pull an already constructed image.
docker tag <image_name><image_name>:<tag>
This command is used to add a TAG to an image.
docker inspect <friendly-name|container-id>
This command is used to learn more about a docker container.
docker inspect <image_name>
This is similar to the command listed above. However, instead of learning more about a container, it is used to learn more about an individual image.
docker save <image_name>><file>.tar
This command is used to save image to a TAR file.
docker rmi <image_name>:<TAG>
This command will delete the image with the <image_name> identifier.
docker rmi `docker images -q`
This command will delete all images in the container.
docker run -v <host_unit>:<docker_unit> -it –name <container_name> -d <image_name>
This command is used to execute a container.
docker rm <container_name>
This command is used to remove a container.
docker rm `docker ps -a -q`
This command will eliminate all stopped containers.
docker images
This command provides a list of images.
docker run -it image_name sh
This command can view content of an image:
docker ps -a
This command will provide a list of containers in execution.
docker exec -i -t a9ddb677957f /bin/bash
This command will connect to a running container.
CMD tail -f /dev/null
This command will configure Dockerfile to keep the docker running.
docker-compose up -d
This command will create a docker-compose background.
docker-compose logs -f -t
This will let you see the deleted logs after the docker is destroyed.
docker-compose down
This command will stop a Docker-Compose command that is still in process.
docker-compose down -v
This command will stop both a Docker-Compose and delete process.
docker-compose ps
This command will let you see a Docker-Compose that is currently being executed.\
docker-compose exec <name-service> /bin/bash
This command will execute a command in a docker-compose container.