Docker - 在CentOS 7中安裝Docker

在CentOS 7中安裝Docker

1-確認系統信息

# cat /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core) 
# uname -a
Linux CentOS-7 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

2-安裝docker

# yum -y install docker

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服務
[root@CentOS-7 ~]# systemctl start docker.service

設置自啟動docker服務

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

4-設置docker代理

# vim /etc/sysconfig/docker
根據實際需要添加相應內容

HTTP_PROXY=http://10.144.1.10:8080
#HTTPS_PROXY=https://10.144.1.10:8080
#FTP_PROXY=ftp://10.144.1.10:8080

注意:一般情況下,國內鏡像設置或代理設置,只需要完成一種配置就可以了。

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:latestHello 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 theexecutable that produces the output you are currently reading.4. The Docker daemon streamed that output to the Docker client, which sent itto your terminal.To try something more ambitious, you can run an Ubuntu container with:$ docker run -it ubuntu bashShare images, automate workflows, and more with a free Docker Hub account:https://hub.docker.comFor 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

增加以下內容
[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"

重啟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

示例 - 在CentOS7系統安裝docker并運行鏡像(使用國內鏡像)

[root@CentOS7 ~]# route add default gw 10.0.3.2
[root@CentOS7 ~]# 
[root@CentOS7 ~]# yum -y install docker
[root@CentOS7 ~]# vim /etc/selinux/config
[root@CentOS7 ~]#  cat /etc/selinux/config |grep "SELINUX="
# SELINUX= can take one of these three values:
SELINUX=disabled
[root@CentOS7 ~]# 
[root@CentOS7 ~]# setenforce 0
[root@CentOS7 ~]# 
[root@CentOS7 ~]# systemctl start docker.service
[root@CentOS7 ~]# systemctl enable docker.service
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@CentOS7 ~]# systemctl is-enabled docker.service
enabled
[root@CentOS7 ~]# 
[root@CentOS7 ~]# sudo mkdir -p /etc/docker
[root@CentOS7 ~]# sudo tee /etc/docker/daemon.json <<-'EOF'
> {
>   "registry-mirrors": ["https://t5t8q6wn.mirror.aliyuncs.com"]
> }
> EOF
{"registry-mirrors": ["https://t5t8q6wn.mirror.aliyuncs.com"]
}
[root@CentOS7 ~]# systemctl daemon-reload
[root@CentOS7 ~]# systemctl restart docker
[root@CentOS7 ~]# 
[root@CentOS7 ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
[root@CentOS7 ~]# 
[root@CentOS7 ~]# 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:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7Hello 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 theexecutable that produces the output you are currently reading.4. The Docker daemon streamed that output to the Docker client, which sent itto your terminal.To try something more ambitious, you can run an Ubuntu container with:$ docker run -it ubuntu bashShare 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/[root@CentOS7 ~]# 
[root@CentOS7 ~]# docker images
REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
docker.io/hello-world   latest              48b5124b2768        3 months ago        1.84 kB
[root@CentOS7 ~]# 

轉載于:https://www.cnblogs.com/anliven/p/6202083.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/259905.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/259905.shtml
英文地址,請注明出處:http://en.pswp.cn/news/259905.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

HDU 1715 大菲波數 (大數問題)

/* 復習大數問題&#xff1b; */ #include <iostream> #include <cstdlib> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <string> #include <iomanip> using namespace std;int nu…

springcloud 相同服務名_SpringCloud系列之SpringCloud Stream

SpringCloud Stream技術興起的原因&#xff1a;為了解決系統中不同中間件的適配問題&#xff0c;出現了cloud stream&#xff0c;采用適配綁定的方式&#xff0c;自動給不同的MQ之間進行切換。屏蔽底層消息中間件的差異&#xff0c;降低切換成本&#xff0c;統一消息的編程模型…

計算機意外重啟或遇錯誤無法繼續,計算機意外地重新啟動或遇到錯誤如何解決?...

電腦小白在重裝系統后難免會遇到些問題&#xff0c;有的容易處理&#xff0c;有的會有些棘手。那么&#xff0c;計算機意外地重新啟動或遇到錯誤如何解決?今天快啟動小編為大家分享詳細的計算機意外地重新啟動或遇到錯誤的解決方法&#xff0c;獻給對系統重裝知識不太了解的小…

jqueryui的Tooltip使用方法

http://api.jqueryui.com/tooltip/#option-position&#xff0c;詳細使用方法。 http://jqueryui.com/tooltip/&#xff0c;DEMO。 content使用 $( ".selector" ).tooltip({ content: "Awesome title!" });//div及相關標簽使用樣式&#xff0c;鼠標放上去時…

iOS 開發者賬號共用發布證書 (Distribution)問題

蘋果客服回復&#xff1a; 1.第一臺申請發布證書的電腦&#xff0c;從鑰匙串中導出發布證書(Distribution)頒發的request文件&#xff1f;然后在第二臺電腦上用request文件新生成一個Distribution證書&#xff0c;這個是可以共用的&#xff1f;&#xff08;不理解還是理解錯了&…

JMeter web 測試

2019獨角獸企業重金招聘Python工程師標準>>> JMeter web 測試 http://jmeter.apache.org/usermanual/build-web-test-plan.html 轉載于:https://my.oschina.net/276172622/blog/808957

scala 連接oracle_一分鐘教你學會用java連接Oracle數據庫

package java_jdbc;//java連接Oracle數據庫import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.Statement;public class JdbcOracleTest {public static void main(String[] args) {// TODO Auto-generated method stub//1.…

計算機軟件記不住設置,想知道電腦密碼記不住了怎么辦

635509517回答數&#xff1a;23216 | 被采納數&#xff1a;32017-01-09 17:51:10方法一&#xff1a;(1)啟動電腦&#xff0c;使用DOS啟動盤(比如&#xff1a;Windows 98啟動盤)進入純DOS狀態。(2)在DOS提示符下&#xff0c;根據下面步驟操作&#xff1a;cd\\ (切換到根目錄)c…

vue-cli#2.0 webpack 配置分析

目錄結構&#xff1a; ├── README.md ├── build │ ├── build.js │ ├── check-versions.js │ ├── dev-client.js │ ├── dev-server.js │ ├── utils.js │ ├── webpack.base.conf.js │ ├── webpack.dev.conf.js │ └── webpack.prod.conf.js…

initWithNibName與viewDidLoad的執行關系以及順序

一個ViewController&#xff0c;一般通過init或initWithNibName來加載。二者沒有什么不同&#xff0c;init最終還是要調用initWithNibName方法&#xff08;除非這個ViewController沒有nib文件&#xff09;。 我們經常在initWithNibName方法中初始化視圖&#xff0c;變量或者其他…

120xa正反轉參數_你知道變頻器的“正反轉死區時間”嗎?它的“停機方式”有幾種?...

若你我之間有緣&#xff0c;關注作者又何妨&#xff1f;兩情若是久長時&#xff0c;又豈在朝朝暮暮。大家好&#xff01;我是江郎&#xff0c;一個踏踏實實的維修工。本期我們仍然探討兩個問題&#xff0c;如標題所述&#xff0c;#變頻器#“死區時間”和“停機方式”&#xff0…

【轉】游戲編程中的人工智能技術--神經網絡

原文&#xff1a;http://blog.csdn.net/ecitnet/article/details/1799444 游戲編程中的人工智能技術.>. (連載之一)用平常語言介紹神經網絡(Neural Networks in Plain English)因為我們沒有很好了解大腦&#xff0c;我們經常試圖用最新的技術作為一種模型來解釋它。在我童年…

w8計算機配置要求,win8系統最低配置要求有哪些|win8系統是否有最低配置要求-系統城...

2013-10-17 17:08:08  瀏覽量&#xff1a;5753小編這里要為大家帶來的是win8系統最低配置要求和部分安裝截圖&#xff0c;很多用戶想要將自己的電腦裝上win8&#xff0c;但也不是每一臺電腦都可以安裝win8系統的&#xff0c;為了避免一些低配置的用戶安裝了win8之后卻無法運行…

Session 丟失問題

項目從.NET Framework3.5 升級 .NET Framework4.0后&#xff0c;如果用Response.Redirect();進行頁面的跳轉&#xff0c;服務端會把這個跳轉動作當作是一個“新”的用戶去訪問網頁。 而這個時候&#xff0c;會給這個“新”的用戶一個SessionID&#xff0c;那造成的結果是&#…

財務管理專業應該報計算機二級哪個科目,我是應該報計算機二級還是三級呢

2008-12-01怎樣學好財務管理&#xff1f;“五步”學好財務管理:學習這門課程前&#xff0c;首先就不要認為它“很難”&#xff0c;只要相信“難而不會&#xff0c;會而不難”&#xff0c;充滿信心一定就能學好。我在學習過程中總結了幾條經驗&#xff0c;以供各位學友參考&…

libsvm java 調用說明

libsvm是著名的SVM開源組件&#xff0c;目前有JAVA.C/C,.NET 等多個版本&#xff0c;本人使用的是2.9libsvm命名空間下主要使用類&#xff1a;svm_model 為模型類&#xff0c;通過訓練或加載訓練好的模型文件獲得svm_parameter 為參數類&#xff0c;主要為支持向量機設定參數&a…

java字符串排序_對字符串排序持一種寬容的心態

在Java中一涉及中文處理就會冒出很多問題來&#xff0c;其中排序也是一個讓人頭疼的課題&#xff0c;我們來看下面的代碼&#xff1a;上面的代碼定義一個數組&#xff0c;然后進行升序排序&#xff0c;我們期望的結果是按照拼音升序排列&#xff0c;即為李四、王五、張三&#…

rails開發隨手記-0

helper默認是只在view中可用的&#xff0c;如果在controller中也要使用&#xff0c;要在ApplicationController中 include 如果model中如果有叫做type的列的話&#xff0c;會觸發rails的Single Table Inheritance &#xff0c;放棄它吧&#xff0c;不好用&#xff0c;還是安心使…

nagios 監控配置介紹(二)

#配置服務端監控客戶端[rootnagios etc]# cd objects/[rootnagios objects]# vi hosts.cfg# Define a host for the local machinedefine host{use linux-serverhost_name 1.3-sambaalias 1.3-sambaaddress …