docker-command
difference between image and container
We can build or image on local or from docker hub.Then We run container from image,you can run multi-containers from a image with --name=appname
.
install docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
Add a Non-Root User to the Docker Group
this require you are login to non-root user on OS
sudo usermod -aG docker Pi
remove docker
sudo apt-get purge docker-ce
sudo rm -rf /var/lib/docker
build docker image
image_name:tag
sudo docker build -t ankisyncd:latest .
container run,start,stop,remove
run container in foreground (add -d to run in background)
sudo docker run -it ankisyncd:latest
start and stop container
docker container stop container_name
docker container start container_name
look up IP address in a container
docker ps -a
to get container_name
docker inspect container_name | grep Address
remove image and container
remove image
run docker images
to get IMAGE ID
,
then run sudo docker rmi 8458e1ca9dca
remove container
run docker ps -a
to get CONTAINER ID
,
then run sudo docker rm 97590f6d5deb
Volume for persist data
add VOLUME /app
in Dockerfile
show Volume
docker volume list
remove the volume by volume name
docker volume rm 962b2d970bcd96de860b348130a84aa86c0aaa55378b3dce35225659679ff808
reference
- Post title:docker-command
- Post author:冬柠
- Create time:2022-05-16 08:42:46
- Post link:docker-command/
- Copyright Notice:All articles in this blog are licensed under BY-NC-SA unless stating additionally.