How To Use Docker?

Install Docker Desktop or Docker Engine

Verify installation with `docker –version`

Start the Docker service

Pull an image with `docker pull `

List local images with `docker images`

Run a container with `docker run `

Run a container in detached mode with `docker run -d `

Name a container with `docker run –name `

Map ports with `docker run -p : `

Mount volumes with `docker run -v : `

View running containers with `docker ps`

View all containers with `docker ps -a`

Stop a container with `docker stop `

Start a stopped container with `docker start `

Restart a container with `docker restart `

Remove a container with `docker rm `

Remove an image with `docker rmi `

View container logs with `docker logs `

Open a shell in a running container with `docker exec -it sh`

Build an image from a Dockerfile with `docker build -t .`

Tag an image with `docker tag :`

Push an image to a registry with `docker push :`

Use `docker compose up` to start multi-container apps

Use `docker compose down` to stop and remove compose services

Inspect containers with `docker inspect `

Clean unused resources with `docker system prune`

Suggested for You

Trending Today