Created
February 6, 2016 08:48
-
-
Save rriifftt/8976250a20779ad6f08f to your computer and use it in GitHub Desktop.
CentOS 7 に docker をインストールして hello world するまで ref: http://qiita.com/satoshi_iwashita/items/4f77e8c85c2dd094f79f
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl -fsSL https://get.docker.com/ | sh | |
$ systemctl start docker.service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[vagrant@localhost ~]$ curl -fsSL https://get.docker.com/ | sh | |
+ sudo -E sh -c 'sleep 3; yum -y -q install docker-engine' | |
Delta RPMs disabled because /usr/bin/applydeltarpm not installed. | |
warning: /var/cache/yum/x86_64/7/docker-main-repo/packages/docker-engine-selinux-1.10.0-1.el7.centos.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID 2c52609d: NOKEY | |
docker-engine-selinux-1.10.0-1.el7.centos.noarch.rpm の公開鍵がインストールされていません | |
Importing GPG key 0x2C52609D: | |
Userid : "Docker Release Tool (releasedocker) <docker@docker.com>" | |
Fingerprint: 5811 8e89 f3a9 1289 7c07 0adb f762 2157 2c52 609d | |
From : https://yum.dockerproject.org/gpg | |
Created symlink from /etc/systemd/system/sysinit.target.wants/lvm2-lvmpolld.socket to /usr/lib/systemd/system/lvm2-lvmpolld.socket. | |
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 vagrant | |
Remember that you will have to log out and back in for this to take effect! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo docker run -it --entrypoint "/bin/bash" centos/nginx:1.2 | |
[root@920ea5c72a47 /]# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl -s localhost | |
hello world |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo docker stop *コンテナID* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo docker rm *コンテナID* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ for p in $(sudo docker ps -a -q); do sudo docker rm -f ${p}; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo docker rmi *イメージID* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo usermod -aG docker vagrant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[vagrant@localhost docker]$ docker version | |
Client: | |
Version: 1.10.0 | |
API version: 1.22 | |
Go version: go1.5.3 | |
Git commit: 590d5108 | |
Built: Thu Feb 4 18:34:50 2016 | |
OS/Arch: linux/amd64 | |
Cannot connect to the Docker daemon. Is the docker daemon running on this host? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[vagrant@localhost docker]$ tree | |
. | |
├── Dockerfile | |
└── index.html | |
0 directories, 2 files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM centos | |
MAINTAINER rriifftt rriifftt@gmail.com | |
RUN yum install -q -y epel-release | |
RUN yum install -q -y nginx | |
ADD index.html /usr/share/nginx/html/ | |
EXPOSE 80 | |
ENTRYPOINT ["/usr/sbin/nginx", "-g", "daemon off;", "-c", "/etc/nginx/nginx.conf"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo docker -t centos/nginx:1.0 . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[vagrant@localhost docker]$ sudo docker images | |
REPOSITORY TAG IMAGE ID CREATED SIZE | |
centos/nginx 1.1 80d766bb9338 About an hour ago 356 MB | |
centos/nginx 1.0 d1345ae2d9a6 9 hours ago 356 MB | |
centos latest 61b442687d68 6 weeks ago 196.6 MB | |
hello-world latest 690ed74de00f 3 months ago 960 B |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo docker run -d -p 80:80 centos/nginx:1.1 | |
753d92d2bf360a529e881efaee564f86840e8d2d649f20825a7132093b45683e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo docker ps | |
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES | |
753d92d2bf36 centos/nginx:1.1 "/usr/sbin/nginx -g '" 3 minutes ago Up 3 minutes 0.0.0.0:80->80/tcp determined_tesla |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment