Last active
April 25, 2018 09:18
-
-
Save emilio2hd/689d41af7681d5d89982 to your computer and use it in GitHub Desktop.
Docker Pocket
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Build an image | |
docker build -t <image_name> <dockerfile_path> | |
# Run a container | |
docker run -d -p <host_port>:<container_port> --name <container_name> <image_name> | |
PS1: In this sample, I'm mapping ports with option '-p'. For more details, see below. | |
PS2: You can add links among containers using --link <container_name>:<alias> option. | |
# Start a bash session at a running container | |
docker exec -it <nome_container> bash | |
# See container's log | |
docker logs <nome_container> | |
# See all images on host | |
docker images | |
# See all containers | |
docker ps -a | |
# Remove a container | |
docker rm -f <nome_container> | |
# Remove ALL containers | |
docker rm -f $(docker ps -a -q) | |
# Remove an image | |
docker rmi -f <nome_imagem> | |
# Remove dangling images (Dangling images", images without tag) | |
docker rmi $(docker images -q -f dangling=true) | |
# Copy a file from container to host | |
docker cp <nome_container>:/caminho/no/container /caminho/no/host | |
Exemplo: docker cp app1:/home/ec2-user/log.txt /logs | |
# Docker stats | |
docker stats <nome_container> | |
# Inspect the container's volume source | |
docker inspect --format='{{range $mount := .Mounts}}{{$mount.Source}} -> {{$mount.Destination}}{{"\n"}}{{end}}' <container id> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment