Docker:尝试篇
寫在前面
學習Docker,官方文檔必不可少,官網提供了比較好的文檔支持以及一個交互型教程的幫助,建議最初的時候先以官網為主,出問題后再找一些博客和資料幫助解決。
- 安裝教程:https://docs.docker.com/installation/ubuntulinux/
- 使用教程:https://docs.docker.com/userguide/
- 交互教程:https://www.docker.com/gettingstarted
首先強烈建議玩一遍官方的一個交互式命令行入門教程。甚至要多玩幾遍,加深印象。
安裝
安裝環(huán)境:
- OS:Ubuntu14.04(筆記本)
- Docker:1.6.2
安裝記錄
Ubuntu14.04安裝Docker省卻了更新內核等各種操作,可直接安裝,按照官網的方式即可,只有一步,網上一些博客的安裝方式和官網的方式是不一樣的。自己選擇。
wget -qO- https://get.docker.com/ | shOK,純凈系統(tǒng)安裝,沒報任何令人不愉快的錯誤,安裝完成。
驗證
查看版本:
sudo docker version輸出結果:
Client version: 1.6.2 Client API version: 1.18 Go version (client): go1.4.2 Git commit (client): 7c8fca2 OS/Arch (client): linux/amd64 Server version: 1.6.2 Server API version: 1.18 Go version (server): go1.4.2 Git commit (server): 7c8fca2 OS/Arch (server): linux/amd64查看信息
sudo docker info輸出信息:
(我是安裝成功后寫的文檔,所以會有一些多余的內容,初次使用應該不會出現(xiàn)。另:無形中暴露了自己的機器信息……)
運行一個例子
sudo docker run hello-world輸出結果:
注意其中的This message shows that your installation appears to be working correctly. 證明docker安裝成功了。
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.(Assuming it was not already locally available.)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 bashFor more examples and ideas, visit:http://docs.docker.com/userguide/權限設置
可能(肯定)出現(xiàn)的錯誤
在使用非root用戶登陸的時候,如果命令不加sudo,會有如下錯誤:
test@prairie:/root$ docker info FATA[0000] Get http:///var/run/docker.sock/v1.18/info: dial unix /var/run/docker.sock: permission denied. Are you trying to connect to a TLS-enabled daemon without TLS?這是沒有加sudo引起的權限的問題。
去掉sudo
方法是,新建一個docker用戶組,然后把現(xiàn)有用戶添加進該組即可
sudo usermod -aG docker zhao(假設以zhao用戶登陸)然后再執(zhí)行命令就不會報錯了。
zhao@prairie:~$ docker run hello-world 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.(Assuming it was not already locally available.)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 bashFor more examples and ideas, visit:http://docs.docker.com/userguide/文章來源:http://blog.csdn.net/zhaodedong
轉載于:https://www.cnblogs.com/dantezhao/p/5365166.html
總結
以上是生活随笔為你收集整理的Docker:尝试篇的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 关于Office 中的墨迹功能(可作wo
- 下一篇: JS 获取浏览器窗口大小