Cheatography
https://cheatography.com
This is a basic cheatsheet for Docker
Building Docker Images
docker build -t <image_name>:<tag> <path_to_Dockerfile> |
Build an image from a Dockerfile |
Dockerfile layering template
FROM <image_name>:<tag> |
Includes the OS & sometimes the runtime environment |
WORKDIR /app |
Specifies which directory to work in |
COPY . . |
Copying everythin in the root directory into app directory |
RUN npm install |
Installing dependencies |
EXPORT port_number |
Specifies port number |
CMD ["command"] |
Command runs in the container not image |
docker build -t <image name> .
Managing Docker Images
docker images |
List all images |
docker image rm <image_name_or_ID> |
Remove one or more images |
docker image rm <imag_name> -f |
Forcefully delete an image even if it is used |
Running Docker Containers
docker run --name <name> -p local_port:container_port<image_name>:<tag> |
Run a command in a new container with name and specifiying the local port |
docker ps |
List running containers |
docker ps -a |
List all containers |
docker stop <container_name_or_ID> |
Stop one or more running containers |
docker start |
docker start <container_name_or_ID> |
docker container rm <container_name> |
Deleting containers |
Managing Docker Containers
docker rm <container_name_or_ID> |
Remove one or more containers |
docker exec -it <container_name_or_ID> <command> |
Run a command in a running container |
docker logs <container_name_or_ID> |
Fetch the logs of a container |
Docker Compose
docker-compose up |
Start services defined in a docker-compose.yml file |
docker-compose down --rmi all -v |
Stop and remove containers, networks, images, and volumes |
for managing multi-container applications
Miscellaneous
docker pull <image_name>:<tag> |
Pull an image or a repository from a registry |
docker tag <source_image> <target_image> |
Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE |
docker push <image_name>:<tag> |
Push an image or a repository to a registry |
docker inspect <container_or_image_name_or_ID> |
Display detailed information on one or more containers or images |
docker system prune -a |
Delete everything |
|
|
|
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets
More Cheat Sheets by leenmajz