Microsoft Windows [Version 10.0.18362.476]
(c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\rudwn>ssh root@192.168.252.101
root@192.168.252.101's password:
Last login: Mon Dec 2 23:18:04 2019 from gateway
[root@master ~]# systemctl start docker
[root@master ~]# docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
nkvuz4nrvrrowftn6wdkucpcx * master Ready Active Leader 19.03.5
zm9h03xovelvysjzpzca57sfs slave1 Ready Active 19.03.5
ptqfu2ibuzg9guk0e80dlpu8u slave2 Ready Active 19.03.5
[root@master ~]# docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@master ~]# ls
anaconda-ks.cfg docker-compose.yml mydocker
[root@master ~]# cd mydocker/
[root@master mydocker]# ls
Dockerfile app.py docker-compose.yml requirements.txt
[root@master mydocker]# docker --version
Docker version 19.03.5, build 633a0ea
[root@master mydocker]# docker buid --tag=friendlyhello .
unknown flag: --tag
See 'docker --help'.
Usage: docker [OPTIONS] COMMAND
A self-sufficient runtime for containers
Options:
--config string Location of client config files (default "/root/.docker")
-c, --context string Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and
default context set with "docker context use")
-D, --debug Enable debug mode
-H, --host list Daemon socket(s) to connect to
-l, --log-level string Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
--tls Use TLS; implied by --tlsverify
--tlscacert string Trust certs signed only by this CA (default "/root/.docker/ca.pem")
--tlscert string Path to TLS certificate file (default "/root/.docker/cert.pem")
--tlskey string Path to TLS key file (default "/root/.docker/key.pem")
--tlsverify Use TLS and verify the remote
-v, --version Print version information and quit
Management Commands:
builder Manage builds
config Manage Docker configs
container Manage containers
context Manage contexts
engine Manage the docker engine
image Manage images
network Manage networks
node Manage Swarm nodes
plugin Manage plugins
secret Manage Docker secrets
service Manage services
stack Manage Docker stacks
swarm Manage Swarm
system Manage Docker
trust Manage trust on Docker images
volume Manage volumes
Commands:
attach Attach local standard input, output, and error streams to a running container
build Build an image from a Dockerfile
commit Create a new image from a container's changes
cp Copy files/folders between a container and the local filesystem
create Create a new container
diff Inspect changes to files or directories on a container's filesystem
events Get real time events from the server
exec Run a command in a running container
export Export a container's filesystem as a tar archive
history Show the history of an image
images List images
import Import the contents from a tarball to create a filesystem image
info Display system-wide information
inspect Return low-level information on Docker objects
kill Kill one or more running containers
load Load an image from a tar archive or STDIN
login Log in to a Docker registry
logout Log out from a Docker registry
logs Fetch the logs of a container
pause Pause all processes within one or more containers
port List port mappings or a specific mapping for the container
ps List containers
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
rename Rename a container
restart Restart one or more containers
rm Remove one or more containers
rmi Remove one or more images
run Run a command in a new container
save Save one or more images to a tar archive (streamed to STDOUT by default)
search Search the Docker Hub for images
start Start one or more stopped containers
stats Display a live stream of container(s) resource usage statistics
stop Stop one or more running containers
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
top Display the running processes of a container
unpause Unpause all processes within one or more containers
update Update configuration of one or more containers
version Show the Docker version information
wait Block until one or more containers stop, then print their exit codes
Run 'docker COMMAND --help' for more information on a command.
[root@master mydocker]# docker build --tag=friendlyhello .
Sending build context to Docker daemon 6.144kB
Step 1/7 : FROM python:2.7-slim
---> 772727e1e204
Step 2/7 : WORKDIR /app
---> Using cache
---> 794ac755921f
Step 3/7 : COPY . /app
---> 2d4112f176c4
Step 4/7 : RUN pip install --trusted-host pypi.python.org -r requirements.txt
---> Running in 0d3efa56de60
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting Flask
Downloading https://files.pythonhosted.org/packages/9b/93/628509b8d5dc749656a9641f4caf13540e2cdec85276964ff8f43bbb1d3b/Flask-1.1.1-py2.py3-none-any.whl (94kB)
Collecting Redis
Downloading https://files.pythonhosted.org/packages/32/ae/28613a62eea0d53d3db3147f8715f90da07667e99baeedf1010eb400f8c0/redis-3.3.11-py2.py3-none-any.whl (66kB)
Collecting click>=5.1
Downloading https://files.pythonhosted.org/packages/fa/37/45185cb5abbc30d7257104c434fe0b07e5a195a6847506c074527aa599ec/Click-7.0-py2.py3-none-any.whl (81kB)
Collecting Werkzeug>=0.15
Downloading https://files.pythonhosted.org/packages/ce/42/3aeda98f96e85fd26180534d36570e4d18108d62ae36f87694b476b83d6f/Werkzeug-0.16.0-py2.py3-none-any.whl (327kB)
Collecting itsdangerous>=0.24
Downloading https://files.pythonhosted.org/packages/76/ae/44b03b253d6fade317f32c24d100b3b35c2239807046a4c953c7b89fa49e/itsdangerous-1.1.0-py2.py3-none-any.whl
Collecting Jinja2>=2.10.1
Downloading https://files.pythonhosted.org/packages/65/e0/eb35e762802015cab1ccee04e8a277b03f1d8e53da3ec3106882ec42558b/Jinja2-2.10.3-py2.py3-none-any.whl (125kB)
Collecting MarkupSafe>=0.23
Downloading https://files.pythonhosted.org/packages/fb/40/f3adb7cf24a8012813c5edb20329eb22d5d8e2a0ecf73d21d6b85865da11/MarkupSafe-1.1.1-cp27-cp27mu-manylinux1_x86_64.whl
Installing collected packages: click, Werkzeug, itsdangerous, MarkupSafe, Jinja2, Flask, Redis
Successfully installed Flask-1.1.1 Jinja2-2.10.3 MarkupSafe-1.1.1 Redis-3.3.11 Werkzeug-0.16.0 click-7.0 itsdangerous-1.1.0
Removing intermediate container 0d3efa56de60
---> 1959f6bf92e9
Step 5/7 : EXPOSE 80
---> Running in 95f0b698996a
Removing intermediate container 95f0b698996a
---> 840371e46b28
Step 6/7 : ENV NAME World
---> Running in 1b26b7ff8ff7
Removing intermediate container 1b26b7ff8ff7
---> 5d3dd30b0ff8
Step 7/7 : CMD ["python", "app.py"]
---> Running in 1f65305ef829
Removing intermediate container 1f65305ef829
---> 408d1ea93c4a
Successfully built 408d1ea93c4a
Successfully tagged friendlyhello:latest
[root@master mydocker]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
friendlyhello latest 408d1ea93c4a 9 seconds ago 148MB
rudwns273/simple-test second 33ce56db2225 14 hours ago 148MB
rudwns273/simple-test first 13ea1fc55258 23 hours ago 148MB
python 2.7-slim 772727e1e204 9 days ago 137MB
hello-world latest fce289e99eb9 11 months ago 1.84kB
[root@master mydocker]# docker run -p 4000:80 friendlyhello
docker: Error response from daemon: driver failed programming external connectivity on endpoint ecstatic_beaver (cf4b31893e1432d12294178cbc39c68e0411b82b61e4cc65f99a43190c21939a): Error starting userland proxy: listen tcp 0.0.0.0:4000: bind: address already in use.
ERRO[0000] error waiting for container: context canceled
[root@master mydocker]# docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@master mydocker]# docker container ls --all
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
82f0b91dfe1c friendlyhello "python app.py" 50 seconds ago Created ecstatic_beaver
422ed2b286ff rudwns273/simple-test:second "python app.py" 14 hours ago Exited (255) 4 minutes ago 80/tcp simple-test_web.3.qhmna4sw7z8cantaxq3qp3hmo
7e5801a55c4b rudwns273/simple-test:second "python app.py" 14 hours ago Exited (255) 4 minutes ago 80/tcp simple-test_web.2.rvg98xfw1l9ip93g33394qem3
fda147e8903f rudwns273/simple-test:second "python app.py" 14 hours ago Exited (0) 14 hours ago flamboyant_joliot
6bcdd0fb6ad6 33ce56db2225 "python app.py" 14 hours ago Exited (0) 14 hours ago charming_hellman
4971ca848dd8 hello-world "/hello" 14 hours ago Exited (0) 14 hours ago flamboyant_shtern
2b6296c1b397 rudwns273/simple-test:first "python app.py" 14 hours ago Created romantic_turing
3eba9deeb761 rudwns273/simple-test:first "python app.py" 14 hours ago Created relaxed_joliot
c63204a0c66d rudwns273/simple-test:first "python app.py" 14 hours ago Created awesome_hofstadter
9dc21d659470 hello-world "/hello" 15 hours ago Exited (0) 15 hours ago dazzling_gates
[root@master mydocker]# docker stop 82f0b91dfe1c
82f0b91dfe1c
[root@master mydocker]# docker run -p 4000:80 friendlyhello
docker: Error response from daemon: driver failed programming external connectivity on endpoint lucid_tereshkova (db5c8835c6bacc19ca83c4a8d7c4721dfccf8305c099474cd93c42500952d9ee): Error starting userland proxy: listen tcp 0.0.0.0:4000: bind: address already in use.
ERRO[0000] error waiting for container: context canceled
[root@master mydocker]# docker run -p 4000:80 friendlyhello
docker: Error response from daemon: driver failed programming external connectivity on endpoint pedantic_bell (498804a9f0e68e4784e831d81ed076158ba8846d4a662834e9632159b6a25683): Error starting userland proxy: listen tcp 0.0.0.0:4000: bind: address already in use.
ERRO[0000] error waiting for container: context canceled
[root@master mydocker]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
friendlyhello latest 408d1ea93c4a 3 minutes ago 148MB
rudwns273/simple-test second 33ce56db2225 14 hours ago 148MB
rudwns273/simple-test first 13ea1fc55258 23 hours ago 148MB
python 2.7-slim 772727e1e204 9 days ago 137MB
hello-world latest fce289e99eb9 11 months ago 1.84kB
[root@master mydocker]# docker swarm init --advertise-addr 192.168.252.101
Error response from daemon: This node is already part of a swarm. Use "docker swarm leave" to leave this swarm and join another one.
[root@master mydocker]# docker swarm leave
Error response from daemon: You are attempting to leave the swarm on a node that is participating as a manager. Removing the last manager erases all current state of the swarm. Use `--force` to ignore this message.
[root@master mydocker]# docker swarm leave --force
Node left the swarm.
[root@master mydocker]# docker swarm init --advertise-addr 192.168.252.101
Swarm initialized: current node (uuizcn0sunpkntstvr1w2jyjv) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-610n3pl0k7e35w6t04udmgry7muap47jznqvouu0ffm3ykzedd-aki3ch2y825j5aj80v4q8yfyu 192.168.252.101:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
[root@master mydocker]# docker stack deploy -c docker-compose.yml simple-test
Creating network simple-test_webnet
Creating service simple-test_web
[root@master mydocker]# docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
rpwxptli2j70 simple-test_web replicated 5/5 rudwns273/simple-test:second *:4000->80/tcp
[root@master mydocker]# docker stack services simple-test
ID NAME MODE REPLICAS IMAGE PORTS
rpwxptli2j70 simple-test_web replicated 5/5 rudwns273/simple-test:second *:4000->80/tcp
[root@master mydocker]# docker service ps simple-test_web
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
oujensl4id5u simple-test_web.1 rudwns273/simple-test:second slave1 Running Running 41 seconds ago
wii2b31fwxl2 simple-test_web.2 rudwns273/simple-test:second slave2 Running Running 41 seconds ago
xjfgvy3qevha simple-test_web.3 rudwns273/simple-test:second master Running Running 41 seconds ago
k0jzekkynm4y simple-test_web.4 rudwns273/simple-test:second slave1 Running Running 41 seconds ago
sguy1f3ay1co simple-test_web.5 rudwns273/simple-test:second slave2 Running Running 41 seconds ago
[root@master mydocker]# docker container ls -q
1cbe5c2269ba
[root@master mydocker]# docker stack ps simple-test
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
oujensl4id5u simple-test_web.1 rudwns273/simple-test:second slave1 Running Running about a minute ago
wii2b31fwxl2 simple-test_web.2 rudwns273/simple-test:second slave2 Running Running about a minute ago
xjfgvy3qevha simple-test_web.3 rudwns273/simple-test:second master Running Running about a minute ago
k0jzekkynm4y simple-test_web.4 rudwns273/simple-test:second slave1 Running Running about a minute ago
sguy1f3ay1co simple-test_web.5 rudwns273/simple-test:second slave2 Running Running about a minute ago
[root@master mydocker]# docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
uuizcn0sunpkntstvr1w2jyjv * master Ready Active Leader 19.03.5
z9ff0kdfykmwdnpje904becms slave1 Ready Active 19.03.5
u9dgooopz4a1bdkv0oe87asay slave2 Ready Active 19.03.5
[root@master mydocker]# docker stack ps simple-test
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
oujensl4id5u simple-test_web.1 rudwns273/simple-test:second slave1 Running Running about a minute ago
wii2b31fwxl2 simple-test_web.2 rudwns273/simple-test:second slave2 Running Running about a minute ago
xjfgvy3qevha simple-test_web.3 rudwns273/simple-test:second master Running Running about a minute ago
k0jzekkynm4y simple-test_web.4 rudwns273/simple-test:second slave1 Running Running about a minute ago
sguy1f3ay1co simple-test_web.5 rudwns273/simple-test:second slave2 Running Running about a minute ago
[root@master mydocker]#