Docker命令总结

前言

命令来自于官网的get-started教程,放在这里自用

part-1

## List Docker CLI commands
docker
docker container --help ## Display Docker version and info
docker --version
docker version
docker info ## Execute Docker image
docker run hello-world ## List Docker images
docker image ls ## List Docker containers (running, all, all in quiet mode)
docker container ls
docker container ls --all
docker container ls -aq

part-2

docker build -t friendlyhello .  # Create image using this directory's Dockerfile
docker run -p 4000:80 friendlyhello # Run "friendlyname" mapping port 4000 to 80
docker run -d -p 4000:80 friendlyhello # Same thing, but in detached mode
docker container ls # List all running containers
docker container ls -a # List all containers, even those not running
docker container stop <hash> # Gracefully stop the specified container
docker container kill <hash> # Force shutdown of the specified container
docker container rm <hash> # Remove specified container from this machine
docker container rm $(docker container ls -a -q) # Remove all containers
docker image ls -a # List all images on this machine
docker image rm <image id> # Remove specified image from this machine
docker image rm $(docker image ls -a -q) # Remove all images from this machine
docker login # Log in this CLI session using your Docker credentials
docker tag <image> username/repository:tag # Tag <image> for upload to registry
docker push username/repository:tag # Upload tagged image to registry
docker run username/repository:tag # Run image from a registry

part-3

docker stack ls                                            # List stacks or apps
docker stack deploy -c <composefile> <appname> # Run the specified Compose file
docker service ls # List running services associated with an app
docker service ps <service> # List tasks associated with an app
docker inspect <task or container> # Inspect task or container
docker container ls -q # List container IDs
docker stack rm <appname> # Tear down an application
docker swarm leave --force # Take down a single node swarm from the manager

part-4

docker-machine create --driver virtualbox myvm1 # Create a VM (Mac, Win7, Linux)
docker-machine create -d hyperv --hyperv-virtual-switch "myswitch" myvm1 # Win10
docker-machine env myvm1 # View basic information about your node
docker-machine ssh myvm1 "docker node ls" # List the nodes in your swarm
docker-machine ssh myvm1 "docker node inspect <node ID>" # Inspect a node
docker-machine ssh myvm1 "docker swarm join-token -q worker" # View join token
docker-machine ssh myvm1 # Open an SSH session with the VM; type "exit" to end
docker node ls # View nodes in swarm (while logged on to manager)
docker-machine ssh myvm2 "docker swarm leave" # Make the worker leave the swarm
docker-machine ssh myvm1 "docker swarm leave -f" # Make master leave, kill swarm
docker-machine ls # list VMs, asterisk shows which VM this shell is talking to
docker-machine start myvm1 # Start a VM that is currently not running
docker-machine env myvm1 # show environment variables and command for myvm1
eval $(docker-machine env myvm1) # Mac command to connect shell to myvm1
& "C:\Program Files\Docker\Docker\Resources\bin\docker-machine.exe" env myvm1 | Invoke-Expression # Windows command to connect shell to myvm1
docker stack deploy -c <file> <app> # Deploy an app; command shell must be set to talk to manager (myvm1), uses local Compose file
docker-machine scp docker-compose.yml myvm1:~ # Copy file to node's home dir (only required if you use ssh to connect to manager and deploy the app)
docker-machine ssh myvm1 "docker stack deploy -c <file> <app>" # Deploy an app using ssh (you must have first copied the Compose file to myvm1)
eval $(docker-machine env -u) # Disconnect shell from VMs, use native docker
docker-machine stop $(docker-machine ls -q) # Stop all running VMs
docker-machine rm $(docker-machine ls -q) # Delete all VMs and their disk images

Docker 入门 --- 命令总结的更多相关文章

  1. Docker入门命令

    Edit Docker入门命令 # 安装镜像sudo docker pull ubuntu:12.04# 镜像列表sudo docker images# 运行镜像sudo docker run -t ...

  2. docker 入门 命令

    docker 命令 docker images 镜像列表 docker ps 服务列表 docker 隐藏打包文件 .dockerignore .git node_modules npm-debug. ...

  3. Docker入门命令备份

    1.安装Docker curl -sSL https://get.docker.com/ | sh 2.将当前用户加入Docker用户组,这样就不用每次执行docker 命令时加上sudo了 3.查看 ...

  4. Docker入门教程(六)另外的15个Docker命令

    Docker入门教程(六)另外的15个Docker命令 [编者的话]DockerOne组织翻译了Flux7的Docker入门教程,本文是系列入门教程的第六篇,继续介绍Docker命令.之前的第二篇文章 ...

  5. Docker入门教程(二)命令

    Docker入门教程(二)命令 [编者的话]DockerOne组织翻译了Flux7的Docker入门教程,本文是系列入门教程的第二篇,介绍了Docker的基本命令以及命令的用法和功能. 在Docker ...

  6. Docker 入门指南——常用命令

    前面已经介绍了 Docker 的安装方式,本文总结一下使用 Docker 的基本概念和常用命令. 基本概念 镜像 Image 镜像是一些打包好的已有的环境,可以被用来启动和创建容器 容器 Contai ...

  7. Docker入门以及常用命令

    目的: Docker入门 Docker简介 Centos7安装Docker Docker HelloWorld运行原理解析 阿里云镜像仓库配置 Docker常用命令 Docker基本命令 Docker ...

  8. docker入门 基础命令 docker安装

    docker入门   在学一门新知识的时候,超哥喜欢提问,why?what?how? wiki资料 什么是docker Docker 最初是 dotCloud 公司创始人 Solomon Hykes ...

  9. docker入门资料及常用命令

      Docker17中文开发手册 :https://www.php.cn/manual/view/36147.html   Linux部署Docker及常用命令: https://www.cnblog ...

随机推荐

  1. (原)python中不同文件之间使用所谓的全局变量

    转载请注明出处: http://www.cnblogs.com/darkknightzh/p/8108640.html 参考网址: https://www.cnblogs.com/20150705-y ...

  2. (原+转)使用anaconda遇到的问题

    转载请注明出处: http://www.cnblogs.com/darkknightzh/p/6669434.html 使用anaconda怎么感觉都是问题啊.... 1. Intel MKL FAT ...

  3. open()系统调用的实现

    open系统调用的服务例程是sys_open()函数,它接受三个参数:要打开文件的路径名filename, 访问模式的表示flags和文件权限掩码mode.在内核中,sys_open实际调用do_sy ...

  4. 获取客户机的ip和mac地址

    只获取clientIP package com.ppms.utils; import javax.servlet.http.HttpServletRequest; /** * Created by l ...

  5. 树莓派进阶之路 (015) - 树莓派使用DS18B20模块测量温度

    参考:http://shumeipai.nxez.com/2013/10/03/raspberry-pi-temperature-sensor-monitors.html 第一步,允许单总线接口 su ...

  6. 【Algorithm】冒泡排序

    一. 算法描述 冒泡排序思想:依次比较相邻的数据,将小数据放在前,大数据放在后:即第一趟先比较第1个和第2个数,大数在后,小数在前,再比较第2个数与第3个数,大数在后,小数在前,以此类推则将最大的数& ...

  7. 【struts2】名为dispatcher的ResultType

    1)基本使用 名称为“dispatcher”的ResultType,在struts-default.xml里的配置如下: <result-type name="dispatcher&q ...

  8. github上完成个人的站点搭建

    未完待续 很早就想有一个自己的站点了,可是我买不起服务器,不想研究WordPress,ect.无意间,博主发现了github居然可以实现自己梦想,加之网络上的资料偏旧(或则说github+jekyll ...

  9. Visual C++中的TCHAR

    为了使代码兼容ASCII码和Unicode编码,微软公司还提供了通用字符类型TCHAR. 通用字符类型的含义是,假设在项目属性中选择"Unicode字符集".则TCHAR代表WCH ...

  10. appium简明教程(7)——Desired Capabilities详解

    Desired Capabilities在启动session的时候是必须提供的. Desired Capabilities本质上是key value的对象,它告诉appium server这样一些事情 ...