Skip to content

Instantly share code, notes, and snippets.

@SebastiaAgramunt
Last active November 29, 2019 11:53
Show Gist options
  • Save SebastiaAgramunt/fb63214d34e17b86c9a2113797b4344f to your computer and use it in GitHub Desktop.
Save SebastiaAgramunt/fb63214d34e17b86c9a2113797b4344f to your computer and use it in GitHub Desktop.
Docker useful commands
# Check all containers
docker ps -a
# Check all images
docker images
#in docker-compose (docker-compose.yml file)
docker-compose up
# Build an image called datascience from
# the local Dockerfile
docker build -t datascience .
# Run the previous image in a container
# called notebook
# We map port 8888 to 8888
# We map current volume to /home/ inside
# the container.
# -d for detaching the window
docker run -d -v $(pwd):/home/ -p 8888:8888 --name notebook -i datascience
#or directly opening a bash terminal
docker run -it rscript /bin/bash
#bash login to container named notebook
docker exec -it notebook bash
# Stop container notebook
# that has id 05c43a6d3a51
docker stop 05c43a6d3a51
#or
docker stop notebook
#remove
docker rm 05c43a6d3a51
#or
docker rm notebook
# Delete image datascience
# with id 8b8df8a3d55e
docker rmi datascience
#or
docker rmi 8b8df8a3d55e
# Stop and remove all containers
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment