开启docker,并设置开机自启动

老式写法:

service docker start
chkconfig docker on

新式写法:

systemctl  start docker.service
systemctl enable docker.service

Build an image from a Dockerfile

docker build -t friendlyhello .

tag一个image,并push

语法:

docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]
docker push username/repository:tag

示例:

[root@localhost ~]# docker login   //登录
[root@localhost ~]# docker tag friendlyhello ssslinppp/get-started:part1 //tag [root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
friendlyhello latest 0a60bcfe3e8d 28 minutes ago 194MB
ssslinppp/get-started part1 0a60bcfe3e8d 28 minutes ago 194MB
python 2.7-slim d962f7a9f2f1 2 weeks ago 182MB
hello-world latest 1815c82652c0 3 weeks ago 1.84kB [root@localhost ~]# docker push ssslinppp/get-started:part1 //上传 [root@localhost ~]# docker run -p 4000:80 ssslinppp/get-started:part1 //运行测试
* Running on http://0.0.0.0:80/ (Press CTRL+C to quit)

容器相关操作

在容器内运行进程

# 后台执行
docker exec -d containerID CMD
docker exec -d containerID touch /etc/new_config_file # 示例 # 交互式执行
docker exec -t -i containerID /bin/bash

查看容器内进程

docker top containerID

查看容器详细信息

docker inspect containerID

查看容器的端口映射情况

docker port containerID

镜像相关操作

查看镜像是如何被构建出来

docker history imageID


官方提供的常用命令

docker build -t friendlyname .  # Create image using this directory's Dockerfile
docker run -p 4000:80 friendlyname # Run "friendlyname" mapping port 4000 to 80
docker run -d -p 4000:80 friendlyname # Same thing, but in detached mode
docker ps # See a list of all running containers
docker stop <hash> # Gracefully stop the specified container
docker ps -a # See a list of all containers, even the ones not running
docker kill <hash> # Force shutdown of the specified container
docker rm <hash> # Remove the specified container from this machine
docker rm $(docker ps -a -q) # Remove all containers from this machine
docker images -a # Show all images on this machine
docker rmi <imagename> # Remove the specified image from this machine
docker rmi $(docker images -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 all running applications on this Docker host
docker stack deploy -c <composefile> <appname> # Run the specified Compose file
docker stack services <appname> # List the services associated with an app
docker stack ps <appname> # List the running containers associated with an app
docker stack rm <appname> # Tear down an application
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-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 start myvm1 # Start a VM that is currently not running
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-machine scp docker-compose.yml myvm1:~ # Copy file to node's home dir
docker-machine ssh myvm1 "docker stack deploy -c <file> <app>" # Deploy an app

【Docker】docker常用指令的更多相关文章

  1. docker学习常用指令---第五章节

    前面我们了解了docker的基本概念,和docker镜像,端口相关的内容.在具体的实际操作过程中,我们需要了解一些相关的docker操作指令. 一.Docker save指令 指令功能:将指定镜像保存 ...

  2. CentOS 7安装docker和常用指令

    1.安装 yum -y install docker 2.启动 systemctl start docker // 启动 docker -v //查看版本号 systemctl stop docker ...

  3. Docker的使用初探(一):常用指令说明

    目录 Docker的使用初探(一):常用指令说明 为什么要用Docker Docker的安装与简单使用 国内镜像加速 常用指令 Docker的使用初探(一):常用指令说明 前几个星期实践的了,再不记录 ...

  4. Docker Compose 配置文件常用指令

    Docker Compose 配置文件常用指令 YAML文件格式及编写注意事项 YAML是一种标记语言很直观的数据序列化格式,可读性高.类似于XML数据描述语言,语法比XML简单的很多. YAML数据 ...

  5. Centos7 docker 常用指令

    Docker 运行在 CentOS 7 上,要求系统为64位.系统内核版本为 3.10 以上 一.docker的安装及卸载 1.查看当前系统内核版本: [root@docker ~]# uname - ...

  6. docker创建image方法以及常用指令介绍

    docker -help    # 显示帮助 docker COMMAND -help    # 帮助信息更详细 docker start “容器名称”    # 启动一个或多个容器 docker s ...

  7. docker基础——关于安装、常用指令以及镜像制作初体验

    为什么使用docker docker就是一个轻量级的虚拟机,他解决的是服务迁移部署的时候环境配置问题.比如常见的web服务依赖于jdk.Tomcat.数据库等工具,迁移项目就需要在新的机器重新配置这些 ...

  8. centos 7 安装docker 常用指令

    什么是docker l  使用最广泛的开源容器引擎 l  一种操作系统级的虚拟化技术 l  依赖于Linux内核特性:Namespace和Cgroups l  一个简单的应用程序打包工具 docker ...

  9. Dockerfile指令及docker的常用命令

    DockerfileFROM: FROM <image> FROM <image>:<tag> MAINTAINER: MAINTAINER <name> ...

  10. Docker Kubernetes YAML文件常用指令

    YAML文件常用指令 配置文件说明: 定义配置时,指定最新稳定版API(当前为v1). 配置文件应该存储在集群之外的版本控制仓库中.如果需要,可以快速回滚配置.重新创建和恢复. 应该使用YAML格式编 ...

随机推荐

  1. Linux 修改最大连接数脚本

    #!/bin/bashfileMax=$(grep "fs.file-max" /etc/sysctl.conf | wc -l)if [ $fileMax -eq 1 ];the ...

  2. fckeditor配置

    <!DOCTYPE html> <html > <head> <title>发布</title> <meta name="v ...

  3. 简易计算器的java实现

    伪代码 public class MainTestwei { 定义两个数组,List<Double> number和 List<Character>calculation分别用 ...

  4. 【BZOJ3240】【UOJ#124】【NOI2013】矩阵游戏

    终于看懂一道题QAQ然而NOI都是这种难度题怎么玩QAQ 原题: 婷婷是个喜欢矩阵的小朋友,有一天她想用电脑生成一个巨大的n行m列的矩阵(你不用担心她如何存储).她生成的这个矩阵满足一个神奇的性质:若 ...

  5. CH5701 开车旅行

    题意 5701 开车旅行 0x50「动态规划」例题 描述 小A和小B决定利用假期外出旅行,他们将想去的城市从1到N编号,且编号较小的城市在编号较大的城市的西边,已知各个城市的海拔高度互不相同,记城市 ...

  6. LA3641 Leonardo's Notebook

    题意 PDF 分析 给出一个26个大写字母的置换B,是否存在A^2 = B 每个置换可以看做若干个循环的乘积.我们可以把这些循环看成中UVa 10294的项链, 循环中的数就相当于项链中的珠子. A^ ...

  7. nginx常用参数设置

    1)隐藏nginx header 版本号 使用curl -I http://www.10.0.3.46 会发现server那里显示版本号 在nginx.conf的http里添加参数server_tok ...

  8. windows知识

    文章目录 系统 修改远程桌面的端口号 IE选项中reset web setting不可用(灰色)的解决办法 重装系统后,修改默认程序安装目录.我的文档.桌面 路径 Keep network addre ...

  9. 解决winfrom下TextBox不支持透明背景色

    不知道微软扯什么拉鸡蛋子,居然有控件不支持透明,我实在想喷设计的人脑残.尤其可恨的是TextBox不支持,更可恨的是直到最新版.net4.6也不支持.源码又看不见,具体实现细节都不知道,谁能改得动?这 ...

  10. 深入详解美团点评CAT跨语言服务监控(六)消息分析器与报表(一)

    大众点评CAT微服务监控架构对于消息的具体处理,是由消息分析器完成的,消息分析器会轮训读取PeriodTask中队列的消息来处理,一共有12类消息分析器,处理后的结果就是生成各类报表. 消息分析器的构 ...