Docker
16 flashcards · Computer Science · by Visotoniki
Docker run and assign a hostname
docker run --hostname HOSTNAME IMAGE
Delete all stopped containers
docker container prune
Docker run and map a local directory into the container
docker run -v HOST_DIR:TARGET_DIR
Show a list of running containers
docker ps
Show a list of all containers
docker ps -a
Delete a running container
docker rm -f CONTAINER
Copy a file from container to host
docker cp CONTAINER:SOURCE TARGET docker cp web:/index.html index.html
Copy a file from host to container
docker cp TARGET CONTAINER:SOURCE docker cp index.html web:/index.html
Start a shell inside a running container
docker exec -it CONTAINER EXECUTABLE docker exec -it web bash docker exe -it alpine sh
Delete all unused images
docker image prune -a
Build an image from a Dockerfile
docker build DIRECTORY docker build .
Build and tag an image from a Dockerfile
docker build -t IMAGE_TAG DIRECTORY docker build -t web-123 .
Save an image to .tar file
docker save IMAGE > FILE docker save nginx > nginx.tar
Show logs of a container
docker logs CONTAINER
Show stats of running containers
docker stats
Show mapped ports of a container
docker port CONTAINER