네이버 클라우드 플랫폼 무료버전 >< 을 받았다.
Centos 7 만 설치되어 있는 백지 상태 서버이므로, Docker를 설치하도록 한다.
도커 설치
리눅스 배포판 종류를 자동으로 인식해서 패키지를 설치해주는 스크립트 사용!
[root@cookie ~]# wget -qO- https://get.docker.com/ | sh
+ 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-17.05.0.ce-1.el7.centos.noarch.rpm:
Header V4 RSA/SHA512 Signature, key ID 2c52609d: NOKEY Public key for docker-engine-selinux-17.05.0.ce-1.el7.centos.noarch.rpm is not installed
Importing GPG key 0x2C52609D:
Userid : "Docker Release Tool (releasedocker) <[email protected]>"
Fingerprint: 5811 8e89 f3a9 1289 7c07 0adb f762 2157 2c52 609d
From : https://yum.dockerproject.org/gpg
setsebool: SELinux is disabled.
libsemanage.semanage_direct_install_info: Overriding docker module at lower priority 100 with module at priority 400.
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!
WARNING: Adding a user to the "docker" group will grant the ability to run
containers which can be used to obtain root privileges on the
docker host.
Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
for more information.
root 대신 Docker 사용할 계정 추가
# sudo usermod -aG docker cookie
# su - cookie
$ service docker start
도커를 구동
$ service docker start
부팅했을 때 자동으로 실행하기
$ chkconfig docker on
Note: Forwarding request to 'systemctl enable docker.service'.
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-unit-files ===
Authentication is required to manage system service or unit files.
Authenticating as: root
Password:
==== AUTHENTICATION COMPLETE ===
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
==== AUTHENTICATING FOR org.freedesktop.systemd1.reload-daemon ===
Authentication is required to reload the systemd state.
Authenticating as: root
Password:
==== AUTHENTICATION COMPLETE ===
systemctl enable docker.service
이미지 검색&다운(search & pull)
spark와 hdfs를 지원하는 버전으로 이미지를 검색해서 다운받았다.
$ docker search spark-hdfs
$ docker pull bachmann/spark-hdfs
이미지 출력 출력(docker images)
$ docker images
모든 컨테이너 목록 출력(docker ps)
$ docker ps -a
-a 옵션을 사용하면 정지된 컨테이너까지 모두 출력하고, 옵션을 사용하지 않으면 실행되고 있는 컨테이너만 출력함
컨테이너 구동(docker run)
이미지를 컨테이너로 생성하고 Bash Shell을 실행
$ docker run -i -t --name hello ubuntu /bin/bash
docker run <옵션><이미지 이름 or 이미지 ID><실행할 파일>
-i
(interactive),-t
(Pseudo-tty) 옵션을 사용하면 실행된 Bash Shell에 입력 및 출력을 할 수 있습니다. 그리고--name
옵션으로 컨테이너의 이름을 지정할 수 있습니다. 이름을 지정하지 않으면 Docker가 자동으로 이름을 생성하여 지정합니다.
컨테이너 접속(docker attach)
$ sudo docker attach <컨테이너 이름(or ID)>
$ docker exec <컨테이너 이름(or ID)><명령><매개 변수>
% 컨테이너가 실행되고 있는 상태에서만 사용 가능, 정지된 상태에서는 사용할 수 없음
컨테이너 설정보기
[cookie@cookie ~]$ docker inspect <컨테이너ID>
[
{
"Id": "98d35f14a077167045f495d375a4ba32a55b57253d7340674cc3e01c2efcba72",
"Created": "2017-06-13T13:27:36.744116868Z",
"Path": "/bin/bash",
"Args": [],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 13590,
"ExitCode": 0,
"Error": "",
"StartedAt": "2017-06-13T13:27:36.898833341Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:c747572d40060d248802f1c44517db8ab12404b2807202bb2c70fb7da0973022",
"ResolvConfPath": "/var/lib/docker/containers/98d35f14a077167045f495d375a4ba32a55b57253d7340674cc3e0
"HostnamePath": "/var/lib/docker/containers/98d35f14a077167045f495d375a4ba32a55b57253d7340674cc3e01c
"HostsPath": "/var/lib/docker/containers/98d35f14a077167045f495d375a4ba32a55b57253d7340674cc3e01c2ef
"LogPath": "/var/lib/docker/containers/98d35f14a077167045f495d375a4ba32a55b57253d7340674cc3e01c2efcbc2efcba72-json.log",
"Name": "/sandbox",
"RestartCount": 0,
"Driver": "overlay",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"ConsoleSize": [
0,
0
],
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": null,
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DiskQuota": 0,
"KernelMemory": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": -1,
"OomKillDisable": false,
"PidsLimit": 0,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0
},
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay/9e001c94433fb01dc285d96c65ef7cbc02c510e65d26cfe4e32b869
"MergedDir": "/var/lib/docker/overlay/149dda2bc4d9afa8138684899861c4cd96966c59d683cf5d5ecdfd
"UpperDir": "/var/lib/docker/overlay/149dda2bc4d9afa8138684899861c4cd96966c59d683cf5d5ecdfd9
"WorkDir": "/var/lib/docker/overlay/149dda2bc4d9afa8138684899861c4cd96966c59d683cf5d5ecdfd93
},
"Name": "overlay"
},
"Mounts": [],
"Config": {
"Hostname": "98d35f14a077",
"Domainname": "",
"User": "",
"AttachStdin": true,
"AttachStdout": true,
"AttachStderr": true,
"ExposedPorts": {
"80/tcp": {}
},
"Tty": true,
"OpenStdin": true,
"StdinOnce": true,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"/bin/bash"
],
"Image": "c747572d4006",
"Volumes": null,
"WorkingDir": "/root",
"Entrypoint": null,
"OnBuild": null,
"Labels": {
"License": "GPLv2",
"Vendor": "CentOS"
}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "8425a0b17bd188f9540adefa16646dbadc0caf64c38a0598a90713e6cd58ffbf",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"80/tcp": null
},
"SandboxKey": "/var/run/docker/netns/8425a0b17bd1",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "f4e6cb6523c0ce03dccb0824ce912f3e30e8a13cb6195b32d02e9851f4431f44",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:02",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "c06e99d229cbadb3b9735fb97a9714aa590b573e30319b7b75baeb6abaa16794",
"EndpointID": "f4e6cb6523c0ce03dccb0824ce912f3e30e8a13cb6195b32d02e9851f4431f44",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02"
}
}
}
}
]