Redhat/Ubuntu/Windows下安装Docker
2016-07-31 15:32
316 查看
Redhat/Ubuntu/Windows下安装Docker
什么是Docker
Docker是Docker.inc公司开源的一个基于LXC技术之上构建的Container容器引擎,基于Go语言并遵从Apache2.0协议开源。开发者可以搭建他们的应用仅仅一次,就能保证让这个应用保持一致的跑在任何地方。运营人员可以将他们的服务器配置一边,就能跑任何应用。
Docker官网:http://www.docker.com/
在Redhat上安装Docker
确保系统上有curl命令
# yum install curl -y
下载并安装Docker
# curl -fsSL https://get.docker.com/ | sh + sh -c 'sleep 3; yum -y -q install docker-engine'
出现下面的输出说明安装成功。
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. warning: rpmts_HdrFromFdno: Header V4 RSA/SHA1 Signature, key ID 2c52609d: NOKEY Importing GPG key 0x2C52609D: Userid: "Docker Release Tool (releasedocker) <docker@docker.com>" From : https://yum.dockerproject.org/gpg 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!
启动Docker
# /etc/init.d/docker start # /etc/init.d/docker status docker dead but pid file exists
出现上面所述错误。。。
查看错误日志
# tail -f /var/log/docker \nTue Apr 26 17:54:02 CST 2016\n time="2016-04-26T17:54:02.715286173+08:00" level=warning msg="You are running linux kernel version 2.6.32-431.el6.x86_64, which might be unstable running docker. Please upgrade your kernel to 3.10.0." time="2016-04-26T17:54:02.716238287+08:00" level=info msg="Listening for HTTP on unix (/var/run/docker.sock)" /usr/bin/docker: relocation error: /usr/bin/docker: symbol dm_task_get_info_with_deferred_remove, version Base not defined in file libdevmapper.so.1.02 with link time reference
在错误日志中发现
version Base not defined in file libdevmapper.so.1.02 with link time reference,缺少libdevmapper.so.1.02。
安装
# yum install libdevmapper.so.1.02 -y # /etc/init.d/docker restart Stopping docker: [FAILED] Starting docker: [ OK ]
查看日志,发现还是之前的错误,原因在于自带的软件版本太低,自己下载就好了。如下:
下载链接:
device-mapper-libs-1.02.95-2.el6.x86_64.rpm
device-mapper-1.02.95-2.el6.x86_64.rpm
# rpm -ivh device-mapper-1.02.95-2.el6.x86_64.rpm device-mapper-libs-1.02.95-2.el6.x86_64.rpm --force # /etc/init.d/docker restart # /etc/init.d/docker status docker (pid 5607) is running...
至此,我们的Docker就安装好了,那让我们来验证一下吧
# docker run hello-world
Ubuntu下安装Docker
确保系统中有curl命令
$ sudo apt-get update $ sudo apt-get install curl -y
下载并安装Docker
$ sudo curl -fsSL https://get.docker.com/ | sh
启动Docker服务
其实在Ubuntu中安装Docker后会默认启动Docker,你可以使用sudo service docker status查看
$ sudo service docker status docker start/running, process 7934
如果需要手动启动或者重启
Docker可以使用
sudo service docker start或
sudo service docker restart
验证Docker是否正常工作
$ sudo docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 03f4658f8b78: Pull complete a3ed95caeb02: Pull complete Digest: sha256:8be990ef2aeb16dbcb9271ddfe2610fa6658d13f6dfb8bc72074cc1ca36966a7 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. 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/userguide/[/code] 出现上面的部分,则安装成功Windows下安装Docker
要在Windows下运行Docker,要求操作系统一定要是Win7及以上版本的64位操作系统,另外,你必须确保你的电脑支持硬件虚拟化技术并且已经开启该功能。下载Docker Toolbox
下载链接:
https://www.docker.com/products/docker-toolbox安装Docker Toolbox
运行DockerToolbox安装包
点击“Next”
点击”Browse…”选择安装位置,然后点击”Next”
选择所要安装的组件,如果你的电脑上已经安装了某些组件可以把对应的勾号去掉,然后点击”Next”(我电脑上原本已经安装有Git,所以将Git前的勾号去掉)
点击”Next”
点击”Install”
等待安装完成….
点击”Finish”完成安装
该安装包安装完成后,系统上会多出三个软件(如果选择安装所有组件的话):
Oracle VM VirtualBox
Git
Boot2Docker for Windows
桌面上将会多出三个图标:启动Docker
打开文件资源管理器,切到Docker的安装目录下
运行start.sh
此处可能出现如下错误:Error creating machine:Error in drive during machine creation: Unable to start the VM:... ... Looks like something went wrong... Press any key to continue... 或 Error creating machine: Error in driver during machine creation: Maximum number of retries (5) exceeded Looks like something went wrong... Press any key to continue...
解决方法:
http://superuser.com/questions/996785/docker-toolbox-error-creating-machine-error-in-driver-during-machine-creation
参考链接:
http://xautlmx.github.io/2016-03-13-RedHat-Ubuntu-Windows%E4%B8%8B%E5%AE%89%E8%A3%85Docker.html#more
相关文章推荐
- 【原】安装wingrub后,用grub引导安装RedHat失败,无法进入windows!!!&&又一次无法进入windows,在grub rescue模式寻找grub文件,重新引导进入ubuntu
- windows安装docker以及安装ubuntu
- ubuntu/redhat vmware-tools 从新安装 与windows 共享文件夹
- 安装linux系统之后,开机时没有Windows系统选项的解决办法(Ubuntu,Deepin,Centos,Redhat,Fedora)
- qemu的安装步骤详解(适合ubuntu和windows)
- windows下安装ubuntu
- 从windows到ubuntu--软件安装
- 使用wubi在windows中安装ubuntu8.10
- windows下硬盘安装ubuntu7.10
- 硬盘安装windows 7 和ubuntu 9.10双系统
- Windows 7下使用wubi安装Ubuntu9.04+新手常见问题
- 在Windows系统上硬盘安装Desktop版的Ubuntu 7.10的引导过程(转)
- 在Vista/Windows 7下硬盘安装Ubuntu9.04
- 从硬盘安装ubuntu,GRUB丢失windows引导解决方法
- windows下硬盘安装Ubuntu 9.04 实现Ubuntu 和 windows 双系统共存
- ubuntu下安装windows字体
- RedHat下JDK1.6安装-利用alternative实现多版本并存(Ubuntu同理)
- windows xp+windows2003+FreeBSD6.2+Ubuntu7.10安装记录
- windows下ubuntu 8.10 alternate版本安装 (膜拜星星)
- 重新安装windows后修复ubuntu启动