Docker 命令

开机启动 docker :chkconfig docker on

搜索镜像:docker search 镜像名( https://hub.docker.com/explore )

获取镜像:docker pull ubuntu:14.04

查看本机镜像:docker images

运行:docker run -it ubuntu:14.04 /bin/bash

  • -i:允许你对容器内的标准输入 (STDIN) 进行交互。
  • -t:在新容器内指定一个伪终端或终端。
  • --rm:容器退出后随之将其删除

查看正在运行的容器:docker ps -a

创建镜像:

FROM ubuntu:14.04 # 基础镜像
MAINTAINER Docker ws <ws@docker.com> # 维护者信息
RUN apt-get -qq update # 安装软件

构建镜像:docker build -t="ouruser/sinatra:v2" .

  • -t 标记来添加 tag ,指定新的镜像的用户信息。
  • . 是 Dockerfile 所在的路径(当前目录),也可以替换为一个具体的 Dockerfile 的路径。
  • 最终的镜像 id。所有的中间步骤所产生的容器都被删除和清理了。
  • 注意一个镜像不能超过 127 层。

提交镜像:docker commit -m "jdk-8u112_tomcat-8" -a "Shuai" 4503614af3c3 jdk8_tomcat8

  • -m 来指定提交的说明信息,跟我们使用的版本控制工具一样;
  • -a 可以指定更新的用户信息;
  • 之后是用来创建镜像的容器的 ID;
  • 最后指定目标镜像的仓库名和 tag 信息。
  • 创建成功后会返回这个镜像的 ID 信息。

导出镜像:docker save -o ubuntu_14.04.tar ubuntu:14.04

载入镜像:docker load < ubuntu_14.04.tar

移除镜像:docker rmi training/sinatra

停止所有容器:docker stop $(docker ps -a -q)

移除所有容器:docker rm $(docker ps -a -q)

启动已终止容器:docker start id

进入容器:
docker attach b94d7021d093
docker exec -i -t b94d7021d093 /bin/bash

退出不停止容器:Ctrl + q p

挂载数据卷:docker run -d -P --name data_share -v /data/heeking/data_share:/home/data_share jdk_tomcat

  • data_share:容器名
  • /data/heeking/data_share:主机目录
  • /home/data_share:容器目录
  • jdk_tomcat:镜像名

查看长id:docker inspect -f '{{.Id}}' ec7641833786

主机向容器传送文件:cp /sourcefile /var/lib/docker/devicemapper/mnt/ec7641833786f8639342cfee46f256f9d620662e7d0fecd19de4f4e125e88df6/rootfs/home/

容器向主机传送文件:docker cp a77a72ac178c:/var/www/html /var/www/

运行 MySQL 容器:docker run --name dbtest -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root123 -d mysql:5.7

  • --name dbtest:容器名
  • -p 3306:3306:宿主机端口:容器 MySQL 端口
  • -e MYSQL_ROOT_PASSWORD=root123:密码
  • -d mysql:5.7:镜像

https://docs.docker.com

https://yeasy.gitbooks.io/docker_practice/content

https://my.oschina.net/huangyong/blog/372491 (包含升级内核)

https://yq.aliyun.com/articles/65145

http://blog.csdn.net/asd05txffh/article/category/6166827

Docker info报错:
WARN:docker bridge-nf-call-iptables is disabled,
WARN:docker bridge-nf-call-ip6tables is disabled
http://blog.csdn.net/xypds2010/article/details/52212323

Docker存储驱动devicemapper介绍和配置

http://www.dockerinfo.net/2182.html

开机自启动:

[root@localhost yum.repos.d]# systemctl enable docker.service
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@localhost yum.repos.d]# cat /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network.target

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process

[Install]
WantedBy=multi-user.target

转载于:https://www.cnblogs.com/17003WS/p/6843548.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
提供的源码资源涵盖了安卓应用、小程序、Python应用和Java应用等多个领域,每个领域都包含了丰富的实例和项目。这些源码都是基于各自平台的最新技术和标准编写,确保了在对应环境下能够无缝运行。同时,源码中配备了详细的注释和文档,帮助用户快速理解代码结构和实现逻辑。 适用人群: 这些源码资源特别适合大学生群体。无论你是计算机相关专业的学生,还是对其他领域编程感兴趣的学生,这些资源都能为你提供宝贵的学习和实践机会。通过学习和运行这些源码,你可以掌握各平台开发的基础知识,提升编程能力和项目实战经验。 使用场景及目标: 在学习阶段,你可以利用这些源码资源进行课程实践、课外项目或毕业设计。通过分析和运行源码,你将深入了解各平台开发的技术细节和最佳实践,逐步培养起自己的项目开发和问题解决能力。此外,在求职或创业过程中,具备跨平台开发能力的大学生将更具竞争力。 其他说明: 为了确保源码资源的可运行性和易用性,特别注意了以下几点:首先,每份源码都提供了详细的运行环境和依赖说明,确保用户能够轻松搭建起开发环境;其次,源码中的注释和文档都非常完善,方便用户快速上手和理解代码;最后,我会定期更新这些源码资源,以适应各平台技术的最新发展和市场需求。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值