设为首页 收藏本站
查看: 748|回复: 0

[经验分享] How To Install Docker On Ubuntu 13.04 x64 VPS

[复制链接]

尚未签到

发表于 2015-10-13 09:43:58 | 显示全部楼层 |阅读模式

Introduction



In case you're not familiar with Docker, here is the summary of it
and its functionality:



Docker is an open-source engine which automates the deployment of applications as highly portable, self-sufficient containers which are independent of hardware, language, framework, packaging system and hosting provider.


In this tutorial, we're going to build and install Docker on a fresh Ubuntu 13.04 VPS (cloud server) instance from DigitalOcean.



Why Build it?



Docker is still in Alpha, and as such, there's considerable changes and fixes daily. Plus, if you find anything you'd like to improve or fix yourself, it's much easier to contribute if you're already building from source!



Step 1: Create the Virtual Private Server



Docker currently only supports Ubuntu 12.04, 12.10, and 13.04, and only in 64bit architecture. It's currently slightly simpler to install Docker on Ubuntu 13.04 x64.




Create the VPS and once it's done, go ahead and SSH in.



Step 2: Setup the VPS



First, set up a user account, so that we have a place to keep Go and Docker (The user's Home directory). Here, replace USER with your own username.


sudo useradd -m -d /home/USER -s /bin/bash -U USER


Give yourself a password with:


passwd USER


For the purposes of this tutorial, we'll give this user all privileges for use of the sudo command; let's add a group called admin and add our new user to it. This will allow them use of the sudo command.


groupadd admin && usermod -a -G admin USER


Login with:


su USER


We'll use our home directory to store both Go and the Docker repository, so enter it now with:


cd ~/


Next, we need to install some dependencies.


sudo apt-get update
sudo apt-get install linux-image-extra-`uname -r`


When confronted with the following screen, make sure you keep the local version currently installed.




Step 3: Install Go



Docker requires Go 1.1, which we are now going to download, as currently aptitude will install Go 1.0.2.


wget http://go.googlecode.com/files/go1.1.1.linux-amd64.tar.gz
tar xf go1.1.1.linux-amd64.tar.gz
rm go1.1.1.linux-amd64.tar.gz


We need to add some environmental varibles to our .profile to define where our Go installation lives, with


echo "export GOROOT=\$HOME/go" >> ~/.profile
echo "PATH=$PATH:\$GOROOT/bin" >> ~/.profile
source ~/.profile


You should now be able to see the currently installed version of Go. This should give Go version go1.1.1 linux/amd64 or similar.


We now need create a folder and add some more environment variables to our .profile.


mkdir ~/gocode
echo "export GOPATH=\$HOME/gocode" >> ~/.profile
echo "PATH=\$PATH:\$GOPATH/bin" >> ~/.profile
source ~/.profile


The documentation refers to the $GOPATH variable as:



a colon-separated list of paths inside which Go code, package objects, and executables may be found.


Our $GOPATH is where we're going to be storing all of the Docker source and dependencies. Later on, this will let us build Docker with the Go install command, which is handy.



Step 4: Install Docker



Install the other dependencies for Docker:


sudo apt-get install lxc curl xz-utils git mercurial


Create the folder structure for building:


mkdir -p $GOPATH/src/github.com/dotcloud


Clone the Docker repository from github:


cd $GOPATH/src/github.com/dotcloud
git clone https://github.com/dotcloud/docker.git


We can now use Go's helpful go get function to download and install the packages and dependencies we need to build Docker:


cd $GOPATH/src/github.com/dotcloud/docker
go get -v github.com/dotcloud/docker/...


This will also install Docker. To allow us to run the Docker executable as root without specifying the full path, we can symlink it to /usr/local/bin with:


sudo ln -s $GOPATH/bin/docker /usr/local/bin/docker


Now run Docker:


sudo docker -d &


After the previous command has been executed and started, hitting Enter will keep Docker running in the background. Let's test it out! First, pull the base container image:


docker pull base


Once it's downloaded, test launch a new container with:


docker run -t base /bin/echo "Hello, world."


Updating Docker is now as simple as stopping the instance, deleting the binary, pulling the repository, using Go install, and restarting Docker:


sudo kill $(cat /var/run/docker.pid)
rm $GOPATH/bin/docker
cd $GOPATH/src/github.com/dotcloud/docker && git pull origin master
go install -v github.com/dotcloud/docker/...
sudo docker -d &


Conclusion



If you're still new to Docker, there's already a few great resources to get you started: The
Docker Index is a place you can find community-made Docker images, ready to Docker pull into your new installation. If you'd prefer to build a few Dockerfiles yourself, there's a good collection to be found here.






https://www.digitalocean.com/community/tutorials/how-to-install-docker-on-ubuntu-13-04-x64-vps


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-126148-1-1.html 上篇帖子: Docker多容器实践 下篇帖子: Docker安装及其应用部署
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表