8 Essential Docker Commands for Software Developers

Master the 8 essential Docker commands that every software developer should know to build, run, and manage containers efficiently. Boost your productivity and build better software with Docker.

Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Well that all developer is aware of.

Here I have listed some basic docker commands that every software developer should be familiar with.

Note: This list will enrich as days go on. Feel free to write comment is anything missed.

1. List Containers

docker ps 
# your can add available [OPTIONS] belowdocker ps -aq
# only shows IDs

[OPTIONS] few are .. More you can find from here

--all 
# or -a Show all containers (default shows just running)--filter 
# or -f Filter output based on conditions provided--format 
# Pretty -print containers using a Go template

2. Stop Container

docker stop CONTAINER_ID 
# copy container id from docker psdocker stop $(docker ps -aq)
# stop all Running containers

3. Remove Container

docker rm CONTAINER_ID
# Delete Specific containerdocker rm $(docker ps -aq)
# Remove all container

4. List Image

docker image ls 
# List all available images in your machine.docker image ls -aq
# list image ids only

5. Remove Image

docker image rm IMAGE_ID
# Remove specific image docker image rm -f IMAGE_ID
# force remove including dependent child images

6. Build Image

docker image build -t IMAGE_NAME:BUILD_NUMBER .
# build image based on docker file in Current directory (.)

7. Run Image

# Command format -> docker run [OPTIONS] IMAGE [COMMAND] [ARG...] docker run -d --name YourContainerName -p x:y \ # -d will Run container in background and print container ID 
# Docker run on image in port x
# EXPOSE Y from Docker file-e REACT_APP_SOME_ENVIRONMENT = someEnv \
# Set some environment variableIMAGE_NAME:BUILD_NUMBER
# Your image with build number

8. Run Command inside Running Containiner

docker exec -it CONTAINER_NAME sh
# Now you can enter command in the containerExit
# For getting Out from the docker Container

Thanks for reading! 🍻

#docker
 

8 Essential Docker Commands for Software Developers
4.85 GEEK