#Container list
docker ps -a
#Show only running containers
docker container ls
#Show all containers
docker container ls -a
#Delete container
docker rm <CONTAINER ID>
#Image list
docker images
#Delete image
docker rmi <IMAGE ID>
#Get image
docker pull hoge
#Connect to container
docker run -it hoge bin/sh
#Stop container
docker stop <CONTAINER ID>
#Restart the container
docker restart <CONTAINER ID>
#About Docker Compose
#Run in the background
docker-compose up -d
#Stop service
docker-compose stop
#Start service
docker-compose start
#Stopping and destroying services
docker-compose down
#「--rm "option: automatically deleted when container is stopped
docker run --rm openjdk:9 java --version
#「--workdir option: specify working directory
docker run --rm --mount type=bind,src=/home/hoge/docker,dst=/home/test --workdir /home/test openjdk:9 java Hello
#About the network
#Network list
docker network ls
#Create a network
docker network create hoge
#Join the container to the created network
docker run --name nginx --network=hoge -d nginx
#Check network
docker network inspect hoge
#Delete network
docker network rm hoge
#About Volume
#Volume list
docker volume ls
#Volume details
docker volume inspect <Volume ID>
#Update container and commit to image
docker run -t -i hoge /bin/bash #Connect to container
gem install json #Change container
docker commit -m "Added json gem" -a "Kate Smith" \
<Container ID> <image ID>:tag #Create an image based on the modified container
Recommended Posts