Docker环境搭建

 

一。 Linux下安装

  1. 查看版本uname -r
$uname -r
4.13.0-36-generic
hadoop@zhu0129:~$ 

    2. 安装Docker    wget -qO- https://get.docker.com/ | sh

root@ubuntu:~# wget -qO- https://get.docker.com/ | sh
# Executing docker install script, commit: 02d7c3c
+ sh -c apt-get update -qq >/dev/null
+ sh -c apt-get install -y -qq apt-transport-https ca-certificates curl >/dev/null
+ sh -c curl -fsSL "https://download.docker.com/linux/ubuntu/gpg" | apt-key add -qq - >/dev/null
+ sh -c echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial edge" > /etc/apt/sources.list.d/docker.list
+ [ ubuntu = debian ]
+ sh -c apt-get update -qq >/dev/null
+ sh -c apt-get install -y -qq --no-install-recommends docker-ce >/dev/null


+ sh -c docker version
Client:
 Version:	18.03.0-ce
 API version:	1.37
 Go version:	go1.9.4
 Git commit:	0520e24
 Built:	Wed Mar 21 23:10:01 2018
 OS/Arch:	linux/amd64
 Experimental:	false
 Orchestrator:	swarm

Server:
 Engine:
  Version:	18.03.0-ce
  API version:	1.37 (minimum version 1.12)
  Go version:	go1.9.4
  Git commit:	0520e24
  Built:	Wed Mar 21 23:08:31 2018
  OS/Arch:	linux/amd64
  Experimental:	false
If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:

  sudo usermod -aG docker your-user

Remember that you will have to log out and back in for this to take effect!

WARNING: Adding a user to the "docker" group will grant the ability to run
         containers which can be used to obtain root privileges on the
         docker host.
         Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
         for more information.
root@zhu0129:~# 

which wget 
如果没有安装,使用 
sudo apt-get update 
sudo apt-get install wget 

 

3.  启动docker后台服务

 sudo service docker start

 

4.  测试运行 sudo docker run hello-world

hadoop@ubuntu:~$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete 
Digest: sha256:97ce6fa4b6cdc0790cda65fe7290b74cfebd9fa0c9b8c38e979330d547d22ce1
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/

hadoop@zhu0129:~$ 

 

5.  镜像加速

 

二。 centos7

1.   uname -r 查看 centos内核版本  需在3.20以上

164456_mbLX_3746673.png

2.  sudo yum update更新

3.  安装docker

yum -y install docker

164444_INv7_3746673.png

 

4.  启动docker后台服务

service docker start

164550_VfzT_3746673.png

5.  测试运行hello-word

docker run hello-world

164706_JsQe_3746673.png

6. 一般拉取镜像十分缓慢,所以我们需要配置加速器

[root@zhumaster ~]# cd /etc/docker/
[root@zhumaster docker]# ls
certs.d  daemon.json  key.json  seccomp.json
[root@zhumaster docker]# vim daemon.json 

在json文件中添加加速器。 

{
 "registry-mirrors": ["http://hub-mirror.c.163.com"]
}

 

 

转载于:https://www.cnblogs.com/apppointint/p/8885273.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值