1. 程式人生 > >Docker 在CentOS 7中安裝Docker

Docker 在CentOS 7中安裝Docker

1-確認系統資訊

# cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core)
# uname -a
Linux docker 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

2-安裝docker

[[email protected] ~]$ yum list docker-ce --showduplicates | sort -r
[[email protected] ~]$ sudo yum install 17.09.0.ce-1.el7.centos
[sudo] password for shu: 
shu is not in the sudoers file.  This incident will be reported.
解決: [
[email protected]
~]# chmod u+w /etc/sudoers
[[email protected] ~]# vi /etc/sudoers 
最後增加:%sudo ALL=(ALL) NOPASSWD: ALL  #允許使用者組sudo裡面的使用者執行sudo命令,並且在執行的時候不輸入密碼.
[[email protected] ~]# chmod u-w /etc/sudoers
[[email protected] ~]# 
[[email protected] ~]# groupadd sudo
[[email protected]
~]# usermod -aG sudo,adm shu

# yum -y install docker

[[email protected] yum.repos.d]$ yum list docker-ce --showduplicates | sort -r
 * updates: ftp.sjtu.edu.cn
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror, langpacks
 * extras: ftp.sjtu.edu.cn
docker-ce.x86_64            17.09.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.09.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.06.2.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.06.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.06.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.03.2.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.03.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.03.0.ce-1.el7.centos             docker-ce-stable
 * base: ftp.sjtu.edu.cn
Available Packages
[

[email protected] yum.repos.d]$ sudo yum install docker-ce-17.09.0.ce-1.el7.centos

安裝指定版本

3-關閉SELinux和啟動docker服務

關閉SELinux

  • 永久方法:修改/etc/selinux/config檔案中設定SELINUX=disabled ,然後重啟。
  • 臨時方法:執行setenforce 0命令設定SELinux成為permissive模式

    sudo systemctl status firewalld.service
    sudo systemctl stop firewalld.service          
    sudo systemctl disable firewalld.service

啟動docker服務
[[email protected] ~]# systemctl start docker.service

設定自啟動docker服務

[[email protected] ~]# systemctl enable docker.service
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[[email protected] ~]# systemctl is-enabled docker.service
enabled
[[email protected] ~]# 

4-設定docker代理(若需要)

5-重啟docker

# systemctl daemon-reload
# systemctl restart docker

6-安裝驗證

執行官方映象hello-world檔案

# docker run hello-world
Unable to find image 'hello-world:latest' locally
Trying to pull repository docker.io/library/hello-world ... 
latest: Pulling from docker.io/library/hello-world
c04b14da8d14: Pull complete 
Digest: sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9
Status: Downloaded newer image for docker.io/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.
 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 Hub account:
 https://hub.docker.com

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

# 
# docker images
REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
docker.io/hello-world   latest              c54a2cc56cbb        5 months ago        1.848 kB

另外一種Docker代理設定方法(若需要):

修改docker.service檔案
# vim /usr/lib/systemd/system/docker.service
在[Service]部分新增如下內容
Environment="HTTP_PROXY=http://10.144.1.10:8080"
Environment="HTTPS_PROXY=https://10.144.1.10:8080"
Environment="FTP_PROXY=ftp://10.144.1.10:8080"

或者,另外建立代理檔案

# mkdir /etc/systemd/system/docker.service.d
# touch /etc/systemd/system/docker.service.d/proxy.conf
# vim /etc/systemd/system/docker.service.d/proxy.conf

重啟docker
# systemctl daemon-reload
# systemctl restart docker

檢查docker環境變數是否載入

# systemctl show docker --property Environment
Environment=GOTRACEBACK=crash HTTP_PROXY=http://10.144.1.10:8080 HTTPS_PROXY=https://10.144.1.10:8080 FTP_PROXY=ftp://10.144.1.10:8080

Log - Install Docker in CentOS-7

[[email protected] ~]# route add default gw 10.0.3.2
[[email protected] ~]# 
[[email protected] ~]# yum -y install docker
[[email protected] ~]# vim /etc/selinux/config
[[email protected] ~]#  cat /etc/selinux/config |grep"SELINUX="
# SELINUX= can take one of these three values:
SELINUX=disabled
[[email protected] ~]# 
[[email protected] ~]# setenforce 0
[[email protected] ~]# 
[[email protected] ~]# systemctl start docker.service
[[email protected] ~]# systemctl enable docker.service
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[[email protected] ~]# systemctl is-enabled docker.service
enabled
[[email protected] ~]# 
[[email protected] ~]# sudo mkdir -p /etc/docker
[[email protected] ~]# sudo tee /etc/docker/daemon.json <<-'EOF'
> {
>   "registry-mirrors": ["https://t5t8q6wn.mirror.aliyuncs.com"]
> }
> EOF
{
  "registry-mirrors": ["https://t5t8q6wn.mirror.aliyuncs.com"]
}
[[email protected] ~]# systemctl daemon-reload
[[email protected] ~]# systemctl restart docker
[[email protected] ~]# 
[[email protected] ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
[[email protected] ~]# 
[[email protected] ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
Trying to pull repository docker.io/library/hello-world ... 
latest: Pulling from docker.io/library/hello-world
78445dd45222: Pull complete 
Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7

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.
 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/

[[email protected] ~]# 
[[email protected] ~]# docker images
REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
docker.io/hello-world   latest              48b5124b2768        3 months ago        1.84 kB
[[email protected] ~]# 

相關推薦

DockerCentOS 7安裝Docker

1-確認系統資訊 # cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core) # uname -a Linux docker 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 20

[Docker] CentOS 7 離線安裝 Docker 1.12.6

一、  基礎環境             作業系統:CentOS Linux release 7.3.1611 (Core)  64位 二、  安裝步驟     2.1  下載 Docker RPM

Centos 7安裝Docker並采用加速器進行鏡像下載加速

docker 安裝 docker拉取鏡像慢 系統版本:[root@c720120 _data]# cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core) 在Centos 7上安裝Docker$sudo yum u pdate$sudo

centos 7.6 安裝 docker

先移除舊的 docker,然後再安裝 docker-ce。 sudo yum remove docker \ docker-client \ docker-client-latest \

簡單記錄在centos 7安裝docker的過程

首先是要刪除舊版本的docker,使用以下命令: $ sudo yum remove docker \ docker-client \ docker-client-latest \ doc

docker實戰centos 7.4 安裝docker

docker實戰centos 7.4 安裝docker 首發:arppinging 一、docker安裝條件 1.64 bit cpu2.linux kernel 3.10+3.linux kernel 支援 cgroups and namespaces centos 7.4 x64為的滿足條件。實際

centos 7安裝Docker-Compose工具

Docker-Compose是一個部署多個容器的簡單但是非常必要的工具. 安裝Docker-Compose之前,請先安裝 python-pip   安裝 python-pip   1、首先檢查linux有沒有安裝python-pip包,終端執行 pip -V

如何在 CentOS 7 安裝、配置和安全加固 FTP 服務

cte success fire lease 註意 tps tran sub linux 步驟 1:安裝 FTP 服務器 1、 安裝 vsftpd 服務器很直接,只要在終端運行下面的命令。 # yum install vsftpd 2、 安裝完成後,服務先是被禁用的,因

CentOS-7安裝與配置Tomcat8.5

ane dsc 配置 pub add ted tar.gz 分享 cal 第一步:下載Tomcat8.5,通過地址:http://tomcat.apache.org/download-80.cgi下載 最後得到下載文件 apache-tomcat-8.5.15.tar.g

centos 7安裝phpmyadmin

sys 3.2 管理系 https art start ges 數據庫管理系統 執行 安裝phpmyadmin數據庫管理系統//1.下載phpmyadmin包wget https://files.phpmyadmin.net/phpMyAdmin/4.7.0/phpMyA

Centos 7安裝二進制數據庫mariadb最新版本

mysql 數據庫 mariadb 安裝二進制數據庫 my.conf 一:實驗背景;在馬哥教育學習到MYSQL這章時,留作業練習的實驗二:實驗準備;1、先檢查虛擬機上是否存在mariadb: rpm -qa mariadb*,若有的話,則卸載;2、通過yum info mariadb查

centos 7安裝nginx並配置nginx反向代理

nginx linux proxy 反向代理 Nginx是一款輕量級的Web 服務器/反向代理服務器及電子郵件(IMAP/POP3)代理服務器,並在一個BSD-like 協議下發行。其特點是占有內存少,並發能力強,事實上nginx的並發能力確實在同類型的網頁服務器中表現較好,中國大陸使用ngi

CentOS 7安裝與配置JDK8

參考命令:http://www.jb51.net/os/RedHat/73016.html來進行安裝 轉載自:http://blog.csdn.net/czmchen/article/details/41047187 安裝說明 系統環境:centos7 安裝方式:r

如何在CentOS 7安裝核心標頭檔案

在本文中,我們將解釋如何使用預設包管理器從基本儲存庫中安裝CentOS / RHEL 7和Fedora發行版中的核心標頭檔案。 當您在CentOS系統上編譯自定義核心模組(如裝置驅動程式)時,您需要在系統上安裝核心標頭檔案,其中包括Linux核心的C標頭檔案。 核心標頭檔案在安裝或

CentOS 7 安裝 MySQL 8

準備 本文環境資訊: 軟體版本 CentOS CentOS 7.4 MySQL 8.0.x 安裝前先更新系統所有包 sudo yum update 安裝 1. 新增 Yum 包 wget https://dev.mysql.com/get/

CentOS 7 安裝Eclipse 的完整過程

1、下載Eclipse壓縮包 下載路徑 http://mirrors.neusoft.edu.cn/eclipse/technology/epp/downloads/release/luna/SR2/eclipse-jee-luna-SR2-linux-gtk-x86_64

CentOS 7安裝與配置Tomcat-8方法

命令主要參考http://www.jb51.NET/os/RedHat/73032.html 安裝說明 安裝環境:CentOS-7安裝方式:原始碼安裝 軟體:apache-tomcat-8.0.14.tar.gz下載地址:http://tomcat.apache

CentOS 7 安裝nginx伺服器

摘要: yum install -y nginx yum install -y nginx 通過yum安裝的時候提示下面的錯誤 [root@localhost yum.repos.d]# yum install nginx 已載入外掛:fastestmirror, lang

如何在CentOS 7安裝最新Git

Git是在今天的軟體開發行業一個非常有用的版本控制工具。我一直使用Git。於是為Linux公社的讀者寫一篇如何在CentOS 7中安裝Git教程 什麼是Git? 如果你曾經使用過Github這樣的網站或者在Bitbucket 購買過程式碼,把它展示給你的朋友,那麼你可能知道Git是什麼。至少,你肯定對它有過

解決Centos 7安裝LAMP之後Apache無法解析php

遇到這個問題我困了一天,網上各種方法都嘗試了,於事無補。我的php是7.2.6版本 apache2.4版本首先,檢查/etc/httpd/conf.modules.d/10-php.conf該檔案是否存在,不存在的話就得安裝mod_php模組,網上各種方法都試了都不好使,我強