0r0 / docker-commands

Essential Docker Commands Every Developer Should Know

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Essential Docker Commands Every Developer Should Know


It' hard to ignore docker this days if you are a Software Developer. Here I gather the most common docker commands which every developer will need in order to do their job better.


⭕️ Version | 📖 docs

docker version

To see the Installed Docker version info.

⭕️ Search | 📖 docs

docker search [name]

Search for specefic images on the Docker Hub. For example if you want to get Neo4j image run:

docker search neo4j

⭕️ Pull | 📖 docs

docker pull [name]:[TAG]

Pull an image from the Docker Hub

  • [name] is the name for the image. ex: neo4j
  • [TAG] you can sepecify which version of the image you want to pull. If not specified, the latest tag will be used by default.
  • --platform set this option to pull image for the specified platform and OS
  • -a or --all-tags to pull all available tags from the registry
  • -q or --quiet to suppress verbose output

Examples:

docker pull neo4j

this will pull the latest official image for Neo4j.

docker pull --all-tags ubuntu

this will pull all images from ubuntu repository.

docker pull ubuntu:22.04

this will pull a specefic version of ubuntu.

⭕️ Images | 📖 docs

docker images

This will print a list of all docker images on the local system.

⭕️ Run | 📖 docs

docker run [name] [command] [args]

Creates and run a new container from an image.

Examples:

docker run neo4j

simply runs the neo4j image in a new container

docker run --name test -it neo4j

run a container named test form neo4j image

⭕️ PS | 📖 docs

docker ps 

Lists docker running containers. Examples:

docker ps --all

--all or -a list all containers. default just shows running.

docker ps --latest

--latest or -l list the latest created container

⭕️ Restart | 📖 docs

docker restart [CONTAINER]

restart one or more container.

⭕️ Kill | 📖 docs

docker kill [CONTAINER]

Kill one or more containers Examples:

docker kill neo4j_imun postgress-UX59

This will kill these 2 containers.

⭕️ Stop | 📖 docs

docker stop [CONTAINER]

Stop one or more containers.

docker stop -t 10000 Neo4j-98xt

Stops Neo4j container after waiting for a specific time.

⭕️ Build | 📖 docs

docker build [DockerFilePath]

Build an image from a docker file or docker repository.

⭕️ Attach | 📖 docs

docker attach [CONTAINER]

Attach your terminal to a running container to control I/O operations.

⭕️ Exec | 📖 docs

docker exec [CONTAINER] [COMMANDS]

Executes cli commands in a running container.

docker exec ubuntu-76sx touch /tmp/myfile

This will creates a file in ubuntu-76sx container.

docker exec -it ubuntu-76sx sh

This starts a new shell session in the ubuntu-76sx container.

⭕️ Logs | 📖 docs

docker logs [CONTAINER]

See the logs for a given container.

docker logs --follow ubuntu-76sx

Use --follow or -f for display logs of ubuntu-76sx container and follow the output as the logs continues.

docker logs -f --until=30m neo4j-ex54

this will display logs before a specific point in time.

⭕️ Commit | 📖 docs

docker commit [CONTAINER] [REPOSITORY]

Create a new image from a container's changes. The new image will not include any data from the container's volumes.

docker commit neo4j-es87 example/test:v4

This will creates a new image from neo4j-es87 container in example/test repository with v4 as its tag. You can use --change options to apply dockerfile instructions to the new image being created.

⭕️ Compose | 📖 docs

docker compose up -d 

compose command use for create and running multi container docker application and use yaml for configuration application service first open go to directory that docker-compose.yml file is exist then run above command to configuration set for your containers -d command for detach mode


About

Essential Docker Commands Every Developer Should Know

License:GNU General Public License v3.0