docker命令

1.建立镜像
docker build -t friendlyname . # Create image using this directory's Dockerfile
2.运行friendlyhello,docker内部的端口映射到宿主机的4000,我们访问应用用4000
docker run -p 4000:80 friendlyname # Run "friendlyname" mapping port 4000 to 80
3.后台的方式运行
docker run -d -p 4000:80 friendlyname # Same thing, but in detached mode
4.查看运行的容器
docker ps # See a list of all running containers
5.停止运行的容器,id通过 docker ps查看
docker stop # Gracefully stop the specified container
6.查看所有的容器不管是否运行的
docker ps -a # See a list of all containers, even the ones not running

  1. 强制杀死指定的容器
    docker kill # Force shutdown of the specified container
    8.从机器移除指定的容器
    docker rm # Remove the specified container from this machine
    9.移除机器所有的容器
    docker rm $(docker ps -a -q) # Remove all containers from this machine
    10.显示本机包含的所有的镜像
    docker images -a # Show all images on this machine
    11.从本季移除制定的镜像
    docker rmi # Remove the specified image from this machine
    12.从本机移除所有的镜像
    docker rmi $(docker images -q) # Remove all images from this machine
    13.cli下登录docker帐号
    docker login # Log in this CLI session using your Docker credentials
    14.标记要上传到仓库的镜像
    docker tag username/repository:tag # Tag for upload to registry
    15.推送docker镜像到仓库
    docker push username/repository:tag # Upload tagged image to registry
    16.从仓库运行docker镜像
    docker run username/repository:tag # Run image from a registry

docker stack ls # List all running applications on this Docker host
docker stack deploy -c # Run the specified Compose file
docker stack services # List the services associated with an app
docker stack ps # List the running containers associated with an app
docker stack rm # Tear down an application

你可能感兴趣的:(docker命令)