You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docker-compose up # Starts multiple containers from docker-compose.yaml in same dir
docker-compose exec <service> <cmd> # Execute command in running container
docker-compose down # Removes associated containers, networks and volumes
$ docker-compose up -d # start containers in background
$ docker-compose kill # stop containers
$ docker-compose up -d --build # force rebuild of Dockerfiles
$ docker-compose rm # remove stopped containers
$ docker ps # see list of running containers
$ docker exec -ti [NAME] bash # ssh to the container
# list all images
docker images
# tag and publishing
docker tag <id> buonzz/name:version
docker login
docker push buonzz/name
# delete image
docker rmi -f <id>
# run an image
docker run yourusername/docker-whale
# view logs
docker logs [OPTIONS] CONTAINER
# set the port to expose in host
docker run -p 3000 my_image
# start new container interactively
docker container run -it
Docker
docker build . -t <namespace>/<imgname>:<tag> # Build a Dockerfile
docker logs <container> # Show container output
docker volume ls # List all volumes
docker stop $(docker ps -q) # Stop all containers
docker rm -f $(docker ps -aq) # Remove(and stop) all containers
docker container prune # Same as the above command
docker rm $(docker ps -a -q -f "status=exited*") # Removed only stopped containers
docker volume rm $(docker volume ls -q) # Remove all volumes
docker volume prune # Same as above command
docker rm -fv <container> # Removes both container and associated volumes
docker volume rm $(docker volume ls -qf dangling=true) # Remove any associated volumes
docker image prune # Removes any unused images
docker rmi $(docker images -qf dangling=true) # Remove dangling images
docker network ls # List container networks
docker network inspect <network_name> # Show network details
docker inspect <container> # Container info as json
docker inspect -f "{{ .NetworkSettings.Networks.nat.IPAddress }}" <containerid> # Get container IP Address
docker inspect -f '{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq) # Get Ip Address for all containers
# Connect to an existing running container
docker exec -it <container> powershell
# Copy files into a container
docker cp <Host path> <Container ID>:<Container path>
# Example
docker cp /tmp/mydb.mdf d6b75213ef80:/var/opt/mssql/data