Docker 一些简单的命令列表
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 run -d --net=my_bridge --name db training/postgres(image名称) #运行一个容器并绑定到my_bridge网络,若没有指定网络则为默认bridge网络 名字为db,
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

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

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 network ls #查看网络
NETWORK ID NAME DRIVER
18a2866682b8 none null
c288470c46f6 host host
7b369448dccb bridge bridge
#三个默认网络

docker network inspect bridge(网络名称) #检查网络,可以看到所包含的容器
docker network disconnect bridge networktest #断开网络,可以通过断开容器从网络中移除容器。为此,提供网络名称和容器名称。也可以使用容器ID。

docker network create -d bridge(驱动为默认bridge) my_bridge(网络名称) #创建网络

docker inspect --format='{{json .NetworkSettings.Networks}}' db # 查看容器db的网络信息
docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' web #查看容器web的IP地址
docker exec -it db bash #链接容器进入shell,ping web(容器名称而不是容器ip)
docker network connect my_bridge web #将web容器连入my_bridge网络,以便可更网络内其他容器通信,

使用docker-compose 时,注意一下版本对应,不然会报错
Compose和Docker兼容性
compose文件格式版本 docker版本
3.4 17.09.0+
3.3 17.06.0+
3.2 17.04.0+
3.1 1.13.1+
3.0 1.13.0+
2.3 17.06.0+
2.2 1.13.0+
2.1 1.12.0+
2.0 1.10.0+
1.0 1.9.1.+

docker-compose 常用命令

Commands:
build Build or rebuild services
bundle Generate a Docker bundle from the Compose file
config Validate and view the compose file
create Create services
down Stop and remove containers, networks, images, and volumes
events Receive real time events from containers
exec Execute a command in a running container
help Get help on a command
kill Kill containers
logs View output from containers
pause Pause services
port Print the public port for a port binding
ps List containers
pull Pull service images
push Push service images
restart Restart services
rm Remove stopped containers
run Run a one-off command
scale Set number of containers for a service
start Start services
stop Stop services
top Display the running processes
unpause Unpause services
up Create and start containers
version Show the Docker-Compose version information
解释一下

build 构建或重建服务
help 命令帮助
kill 杀掉容器
logs 显示容器的输出内容
port 打印绑定的开放端口
ps 显示容器
pull 拉取服务镜像
restart 重启服务
rm 删除停止的容器
run 运行一个一次性命令
scale 设置服务的容器数目
start 开启服务
stop 停止服务
up 创建并启动容器

Docker 学习记录笔记(一)的更多相关文章

  1. Docker学习记录--入门了解+安装

    Docker简介 Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化.容器是完全使用沙箱机制, ...

  2. Docker 学习新手笔记:从入门到放弃

    本文记录的是作为一个新手,从了解 Docker 是什么.Docker 技术包含哪些概念到上手使用.安装以及发布 Docker 镜像的整个过程.作者在学习过程中参阅了诸多文档和教程,在此一并感谢,与此同 ...

  3. docker学习记录1

    起因 现在自己学习微服务,服务器越来越多,虽然自己写了一些shell脚本来安装需要的软件,比如mysql,redis,jdk等等,但是还是好麻烦.希望学习docker能够快速安装部署这些东西. 记录一 ...

  4. [原创]Docker学习记录: Shipyard+Swarm+Consul+Service Discover 搭建教程

    网上乱七八糟的资料实在是太多了, 乱, 特别乱, 而看书呢, 我读了2本书, 一本叫做<>, 另一本叫做<< Docker进阶与实战>> 在 服务发现这块讲的又不清 ...

  5. 天池Docker学习赛笔记

    容器的基本概念 什么是容器? 容器就是一个视图隔离.资源可限制.独立文件系统的进程集合.所谓"视图隔离"就是能够看到部分进程以及具有独立的主机名等:控制资源使用率则是可以对于内存大 ...

  6. The Docker学习记录[Doing]

    微服务 & Docker 译文:使用Java构建微服务 原文:Building Microservices With Java [编者的话]本文翻译自Dzone Guide to the Ja ...

  7. docker学习------记录centos7.5下docker安装更换国内源的处理过程

    一.centos7.5下更换阿里源 1.装好centos7.5镜像,将yum源更换为阿里源 第一步:刚出的centos7.5是解析不到阿里的东西的,所以找了台centos7.4,下载一些包 (1) 下 ...

  8. docker学习记录

    Container 容器是一种基础工具, 泛指任何容纳其他物品的工具, 可以部分或者完全封闭,被用于容纳,储存, 运输物品, 物体可以放置在容器中, 而容器可以保护内容物 1 Docker Objec ...

  9. Docker 学习记录(基础命令)

    1. 获取镜像 docker pull [选项] [Docker Registry 地址[:端口号]/]仓库名[:标签]  ===>   docker pull ubuntu:16:04 2.运 ...

随机推荐

  1. SIP UserAgent (B2BUA client)——linphonec

    1.linphone编译 linphone一般用在android/ios/windows/mobile上,但是没有图形界面的linphonec命令行程序用在资源紧张的硬件平台上也跟pjsip命令行一样 ...

  2. supervisor配置与应用

    1.简介 supervisor 是一款基于Python的进程管理工具,可以很方便的管理服务器上部署的应用程序.supervisor的功能如下: a. 启动.重启.关闭包括但不限于python进程. b ...

  3. 重新编写equals()方法,hashCode()方法,以及toString(),提供自定义的相等标准,以及自描述方法

    下面给出一个实例,重新编写equals()方法,提供自定义的相等标准 public class PersonTest { public static void main(String[] args) ...

  4. python全栈开发从入门到放弃之socket并发编程之IO模型

    一 IO模型介绍 同步(synchronous) IO和异步(asynchronous) IO,阻塞(blocking) IO和非阻塞(non-blocking)IO分别是什么,到底有什么区别?这个问 ...

  5. Mac下的Mysql无法登陆的问题

    以下是还原root权限和更改root密码的最便捷方法. 1:装mysql workbench .可视化界面直接操作. 2:苹果->系统偏好设置->最下边点mysql 在弹出页面中 关闭my ...

  6. 如何注册iClap账号?

    iClap是一个以产品为基础,集成员工日常所需工具,打通项目工作流程,实现员工自我工作管理.项目管理和企业管理三个体系协同的管理规范系统. 工具/原料 iPhone/Android/浏览器 Teamb ...

  7. 新一批创业者金矿,iclap谁与争锋

    19世纪,美国西部开发,无数拓荒者涌入,并最终因金矿的发现形成了淘金热.而当无数人埋头寻找黄金之时,有一个人却抬起头看到了潜藏在无数淘金者身上的金矿-这个人就是牛仔裤的发明者,Levi’s的创始人-李 ...

  8. hdu6215 Brute Force Sorting

    地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=6215 题目: Brute Force Sorting Time Limit: 1000/100 ...

  9. 简单地理解HTTPS 转

    原文地址:http://www.nowamagic.net/librarys/veda/detail/2394 我们都知道HTTPS能够加密信息,以免敏感信息被第三方获取.所以很多银行网站或电子邮箱等 ...

  10. Linux ./configure --prefix 命令是什么意思?

    源码的安装一般由3个步骤组成:配置(configure).编译(make).安装(makeinstall). Configure是一个可执行脚本,它有很多选项,在待安装的源码路径下使用命令./conf ...