5. Create your first docker environment
• Install VMware Workstation 15 Pro in your laptop
• https://mega.nz/file/zHxlyASC#47BjSzA8iR26nUT4g4YVVWTw0eo-
qchQzPygLI4sE4U
• Install CentOS7 (CentOS-7-x86_64-DVD-2003.iso)
• https://mirrors.aliyun.com/centos/7/isos/x86_64/CentOS-7-x86_64-DVD-
2009.iso
• Install Putty
• https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
6. Create your first docker environment
• System configuration
• Memory: 4096 MB+
• CPU: 1 Processors+
• Hard Disk: 30GB+
7. Create your first docker environment
• Install putty as your terminal tool
• Get your IP RUN => ip addr
8. Create your first docker environment
• Use putty to connect your host
putty.exe
9. Create your first docker environment
• Install docker
• RUN =>
• RUN =>
• RUN =>
• RUN =>
• RUN =>
curl -sSL https://get.docker.com | sh
reboot
systemctl start docker
systemctl status docker
usermod -aG docker root
Add root to dockerroot group
10. Docker CLI
• Command
• RUN =>
• RUN =>
• RUN =>
• RUN =>
• RUN =>
• RUN =>
• RUN =>
docker help
docker run --help
docker search alpine
docker pull alpine
docker images
docker tag alpine orozcohsu/alpine:v1
docker rmi -f orozcohsu/alpine:v1
12. Docker API
• Configuration
• RUN =>
• RUN =>
• RUN =>
• RUN =>
• RUN =>
mkdir /etc/systemd/system/docker.service.d
systemctl daemon-reload
vi /etc/systemd/system/docker.service.d/override.conf
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2375
systemctl restart docker
systemctl stop firewalld; systemctl status firewalld
13. Docker API
• API is enable
• RUN =>
• RUN => docker info
systemctl restart docker
docker service must be restarting because of disable firewall
14. Docker API
• Restful API (pull a image and run)
• RUN =>
• RUN =>
• RUN =>
curl -v -XPOST http://192.168.159.144:2375/images/create?fromImage=nginx:latest
curl http://192.168.159.144:2375/images/json | grep RepoTags
Find local images
curl -v -XPOST http://192.168.159.144:2375/images/create?fromImage=hermsi/alpine-sshd:latest
15. Docker API
• Restful API (pull a image and run)
• RUN => curl -X POST -H "Content-Type: application/json" -d
'{
"Hostname":"", "User":"", "Memory":0,
"MemorySwap":0, "AttachStdin":false,
"AttachStdout":true,"AttachStderr":true,
"PortSpecs":null,"Tty":false,"OpenStdin":false,
"StdinOnce":false,"Env":null,"Cmd":["nginx", "-g", "daemon off;"],
"Image":"nginx", "Tag":"latest",
"Volumes":{"/tmp":{}},
"WorkingDir":"","DisableNetwork":false,
"ExposedPorts":{"22/tcp": {} }
}' http://192.168.159.144:2375/containers/create
Try to check container status
16. Docker API
• Restful API (pull a image and run)
• RUN =>
• RUN =>
curl -X POST http://192.168.159.144:2375/containers/ID/start
The initialized status of docker is in Created, use start to change its status to Up
curl http://192.168.159.144:2375/containers/json?all=1
Try to docker exec and go to container
17. Docker API
• Restful API (check container)
• RUN =>
• RUN =>
• RUN =>
• RUN =>
curl -X POST http://192.168.159.144:2375/containers/ID/stop
curl -X POST http://192.168.159.141:2375/containers/ID/restart?t=5
curl -X POST http://192.168.159.141:2375/containers/ID/kill
curl http://192.168.159.144:2375/containers/ID/top
number of seconds to wait before killing the container
Try to check container status
20. Docker network
• Try to synchronize local folder with container volume
• RUN =>
• RUN =>
docker run -d --rm -p 4001:22 --env ROOT_PASSWORD=1234 hermsi/alpine-sshd
docker run -d --rm -p 4002:22 --env ROOT_PASSWORD=1234 hermsi/alpine-sshd
Try to check container information
22. Docker volume
• Try to use putty and connect to different linux container
• RUN =>
• RUN =>
docker run -d --rm -v /tmp/app:/app --env ROOT_PASSWORD=1234 hermsi/alpine-sshd
touch /tmp/app/test.txt
Try to check local folder /tmp/app and container folder /app