1.系统环境 CentOS-7.0-1406-x86_64-Minimal 2.安装 # yum install docker 安装 golang 环境 # yum install go # go version go version go1.2 linux/amd64 3.启动 用系统管理启动 # systemctl start docker.service 开机自启动 # systemctl enable docker.service 查看状态 # systemctl status docker.service docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled) Active: active (running) since Fri 2014-08-22 22:06:55 CST; 4min 23s ago Docs: http://docs.docker.io Main PID: 2177 (docker) CGroup: /system.slice/docker.service └─2177 /usr/bin/docker -d --selinux-enabled 4.安装 ubuntu # docker pull ubuntu 注:当镜像下载成功后,你可以看到12位的hash值像539c0211cd76,这是下载完整的镜像的精简ID,这些短的镜像ID是完整镜像ID的前12个字符--可以使用docker inspect 或者 docker images -notrunc=true来获得完整的镜像ID # docker inspect 92ac38e49c3e [{ "id": "92ac38e49c3ead6c4c7613a7430fd3c07d2a8581aab5e3fb48e6c53c06468838", "parent": "f33dbb8bc20e738289b01a878b13f0898cc902d7412806e371d80c942c8dcf55", "created": "2014-08-12T03:29:17.16719591Z", "container": "887cb2ca175dc8f7d8aaba44fb85f6ec408035ee8e75b6d397a49b4275374d3a", "container_config": { "Hostname": "b3799a3c1a51", "Domainname": "", "User": "", "Memory": 0, "MemorySwap": 0, "CpuShares": 0, "Cpuset": "", "AttachStdin": false, "AttachStdout": false, "AttachStderr": false, "PortSpecs": null, "ExposedPorts": null, "Tty": false, "OpenStdin": false, "StdinOnce": false, "Env": [ "HOME=/", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ], "Cmd": [ "/bin/sh", "-c", "rm -rf /var/lib/apt/lists/*" ], "Image": "f33dbb8bc20e738289b01a878b13f0898cc902d7412806e371d80c942c8dcf55", "Volumes": null, "WorkingDir": "", "Entrypoint": null, "NetworkDisabled": false, "OnBuild": [] }, "docker_version": "1.1.2", "config": { "Hostname": "b3799a3c1a51", "Domainname": "", "User": "", "Memory": 0, "MemorySwap": 0, "CpuShares": 0, "Cpuset": "", "AttachStdin": false, "AttachStdout": false, "AttachStderr": false, "PortSpecs": null, "ExposedPorts": null, "Tty": false, "OpenStdin": false, "StdinOnce": false, "Env": [ "HOME=/", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ], "Cmd": null, "Image": "f33dbb8bc20e738289b01a878b13f0898cc902d7412806e371d80c942c8dcf55", "Volumes": null, "WorkingDir": "", "Entrypoint": null, "NetworkDisabled": false, "OnBuild": [] }, "architecture": "amd64", "os": "linux", "Size": 0 }] 用ubuntu环境执行 # docker run -i -t ubuntu /bin/bash root@ef8129838857:/# cat /etc/issue Ubuntu 14.04.1 LTS \n \l 5.安装 fedora # docker run -i -t fedora /bin/bash 注意: CentOS 开机自启动 为 systemctl enable docker.service 查看状态为 systemctl status docker.service 用 systemctl start docker.service 启动之后 不需要 docker -d & (责任编辑:IT) |