Docker技术之环境搭建(一)

近日在研究容器相关的技术,看了vagrantDocker,最终我选择两个都研究下,现在我们来看看Docker的环境搭建。

零. 前期说明

笔者所有的操作系统是DeepIn 15.5,这个由深度科技基于Debian开发的操作系统。

基于以上的条件,我们安装Docker也会参考Docker官网上关于Debian的安装手册。

传送门:Get Docker CE for Debian官方手册

一、准备工作

扫盲

English 中文
host 本地主机
image 镜像
contianer 容器
registry 仓库
daemon 守护进程
client 客户端

卸载之前的Docker

sudo apt-get remove docker docker-engine docker.io

更新apt软件索引

sudo apt-get update

二、开始安装Docker

安装所依赖的库文件

sudo apt-get install \
     apt-transport-https \
     ca-certificates \
     curl \
     gnupg2 \
     software-properties-common \
     python-software-properties

添加Docker的官方GPG

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - 

添加source.list添加Docker

sudo add-apt-repository  "deb [arch=amd64] https://download.docker.com/linux/debian wheezy stable“ 

最后更新源

sudo apt-get update

三、安装Docker-ce

sudo apt-get -y install docker-ce 

root用户身份管理Docker

创建docker用户组

sudo groupadd docker

将当前用户添加到docker用户组

sudo gpasswd -a ${USER} docker  

修改docker.sock的权限

sudo chmod a+rw /var/run/docker.sock

四、注销并重新登

到目前为止,dockerDeepin中已经安装完成,现在可以注销并重新登录你的组成员权限。

五、检测权限

docker run hello-world

验证您可以运行docker命令时不需要添加sudo

该命令会下载一个测试Image并在容器中运行。

如果成功了,可以看到一下信息:

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete 
Digest: sha256:66ef312bbac49c39a89aa9bcc3cb4f3c9e7de3788c944158df3ee0176d32b751
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://cloud.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/

六、禁止Docker开机自动启动

安装chkconfig

sudo apt-get install chkconfig 

禁止开机自动启动

sudo chkconfig --del docker
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 今天就结合深度桌面操作系统给大家讲讲桌面操作系统的架构设计和原理细节,一来向外界讲讲深度这么多年都做了哪些工作,二...
    ManateeLazyCat阅读 71,582评论 208 616
  • Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流...
    ProteanBear阅读 5,177评论 0 3
  • 注意: 该 Docker 版本为了支持 Docker 机,于是不再支持 Boot2Docker 命令行。使用 Do...
    提莫队长1234阅读 10,090评论 0 8
  • 在前些天的毕业聚会上,一个叫阿华的姑娘喝断片了,没有撒酒疯,反而是把她那本来洒脱的性格展现的淋漓尽致。 我有幸与她...
    称愿姑娘阅读 1,819评论 0 0
  • 偶然一次 那旷荡的操场正中部 在软软的草地上躺下 静静地 静静地 欣赏那一颗颗闪烁的精灵 仿佛听到自己的心 和大地...
    文德学习社阅读 1,950评论 0 3

友情链接更多精彩内容