Skip to content

Instantly share code, notes, and snippets.

@rriifftt
Created February 6, 2016 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rriifftt/8976250a20779ad6f08f to your computer and use it in GitHub Desktop.
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
$ curl -fsSL https://get.docker.com/ | sh
$ systemctl start docker.service
[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!
$ sudo docker run -it --entrypoint "/bin/bash" centos/nginx:1.2
[root@920ea5c72a47 /]#
$ curl -s localhost
hello world
$ sudo docker stop *コンテナID*
$ sudo docker rm *コンテナID*
$ for p in $(sudo docker ps -a -q); do sudo docker rm -f ${p}; done
$ sudo docker rmi *イメージID*
$ sudo usermod -aG docker vagrant
[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?
[vagrant@localhost docker]$ tree
.
├── Dockerfile
└── index.html
0 directories, 2 files
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"]
$ sudo docker -t centos/nginx:1.0 .
[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
$ sudo docker run -d -p 80:80 centos/nginx:1.1
753d92d2bf360a529e881efaee564f86840e8d2d649f20825a7132093b45683e
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