DEV Community

Anass Assim
Anass Assim

Posted on

1

πŸ“ Docker Images Cheat Sheet πŸš€

Command Description
docker pull nginx Pulls the latest Nginx image from Docker Hub.
docker images Lists all Docker images on the local machine.
docker ps Lists all running containers.
docker run -d nginx:latest Runs an Nginx container in detached mode using the latest version.
docker run -d -p 8080:80 nginx:latest Runs Nginx in detached mode and maps port 8080 on the host to port 80 in the container.
docker run -d -p 8080:80 -p 3000:80 nginx:latest Runs Nginx in detached mode and maps multiple ports (8080 and 3000).
docker ps -a Lists all containers (including stopped ones).
docker exec -it $ID Executes a command inside a running container (replace $ID with container ID).
docker rm $(docker ps -aq) Removes all stopped containers.
docker run --name "MyPage" -d -p 8080:80 nginx:latest Runs a container named "MyPage" with port mapping.
cd /home/user/myhtml && docker run --name "MyPage" -v $(pwd):/usr/share/nginx/html:ro -d -p 8080:80 nginx Runs a container and mounts the local HTML folder to the container.
docker exec -it $container_name bash Opens a bash shell in the running container (replace $container_name).
docker run --name "copy-of-mypage" --volumes-from "mypage" -d -p 8081:80 nginx Runs a new container using the same volumes as "mypage" and maps port 8081.

Billboard image

Deploy and scale your apps on AWS and GCP with a world class developer experience

Coherence makes it easy to set up and maintain cloud infrastructure. Harness the extensibility, compliance and cost efficiency of the cloud.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs