Question : The Nautilus DevOps team is working to deploy one of the applications on App Server 2 in Stratos DC. Due to a misconfiguration in the docker compose file, the deployment is failing. We would like you to take a look into it to identify and fix the issues. More details can be found below:
a. docker-compose.yml file is present on App Server 2 under /opt/docker directory.
b. Try to run the same and make sure it works fine.
c. Please do not change the container names being used. Also, do not update or alter any other valid config settings in the compose file or any other relevant data that can cause app failure.
Note: Please note that once you click on FINISH button all existing running/stopped containers will be destroyed, and your compose will be run.
Please Note :- Perform the below commands based on your question server, user name & other details might differ . So please read task carefully before executing. All the Best 👍
Solution:
1. At first login on app server as per the task & Switch to root user
|
thor@jump_host
/$ ssh steve@stapp02 The authenticity
of host 'stapp02 (172.16.238.11)' can't be established. ECDSA key
fingerprint is SHA256:yduRjz6i7UrP54yLhdypCGIBtcn4X1Q+7uSLcgj/gP8. ECDSA key
fingerprint is MD5:7d:df:f4:8a:d4:d8:8f:65:63:d7:b5:0a:8e:b1:6d:29. Are you sure you
want to continue connecting (yes/no)? yes Warning:
Permanently added 'stapp02,172.16.238.11' (ECDSA) to the list of known hosts. steve@stapp02's
password: [steve@stapp02
~]$ sudo su - We trust you have received the usual lecture from the local System Administrator.
It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great
responsibility. [sudo] password for steve: [root@stapp02
~]# |
2. check the existing file docker-compose.yml under /opt/docker directory. File has issue need to rectify Refer Video post below
|
[root@stapp02
~]# cat /opt/docker/docker-compose.yml version: '2' services: web: image: . container_name: python port: - "5000:5000" volumes: - .:/code depends_on: - redis redis_app: image: redis container_name: redis [root@stapp02
~]# |
3. Edit the compose file and rectify the changes
|
[root@stapp02
~]# cd /opt/docker/ [root@stapp02
docker]# vi docker-compose.yml [root@stapp02
docker]# cat docker-compose.yml version: '2' services: web: build: . container_name: python ports: - "5000:5000" volumes: - .:/code depends_on: - redis_app redis_app: image: redis container_name: redis [root@stapp02
docker]# |
|
[root@stapp02
docker]# docker-compose up Creating network
"docker_default" with the default driver Pulling
redis_app (redis:)... latest: Pulling
from library/redis b4d181a07f80:
Pull complete 86e428f79bcb:
Pull complete ba0d0a025810:
Pull complete ba9292c6f77e:
Pull complete b96c0d1da602:
Pull complete 5e4b46455da3:
Pull complete Building web Step 1/5 : FROM
python:2.7 2.7: Pulling
from library/python 7e2b2a5af8f6:
Pull complete 09b6f03ffac4:
Pull complete dc3f0c679f0f:
Pull complete fd4b47407fc3:
Pull complete b32f6bf7d96d:
Pull complete 6f4489a7e4cf:
Pull complete af4b99ad9ef0:
Pull complete 39db0bc48c26:
Pull complete acb4a89489fc:
Pull complete Digest:
sha256:cfa62318c459b1fde9e0841c619906d15ada5910d625176e24bf692cf8a2601d Status:
Downloaded newer image for python:2.7 ---> 68e7be49c28c Step 2/5 : ADD .
/code ---> 909222b8c783 Step 3/5 :
WORKDIR /code ---> Running in 314a1d3edbcb Removing
intermediate container 314a1d3edbcb ---> b0be52b0320c Step 4/5 : RUN
pip install -r requirements.txt ---> Running in 7b87d89ae826 DEPRECATION:
Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade
your Python as Python 2.7 is no longer maintained. 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 Flask-1.1.4-py2.py3-none-any.whl
(94 kB) Collecting redis Downloading
redis-3.5.3-py2.py3-none-any.whl (72 kB) Collecting
click<8.0,>=5.1 Downloading
click-7.1.2-py2.py3-none-any.whl (82 kB) Collecting
Werkzeug<2.0,>=0.15 Downloading
Werkzeug-1.0.1-py2.py3-none-any.whl (298 kB) Collecting
Jinja2<3.0,>=2.10.1 Downloading
Jinja2-2.11.3-py2.py3-none-any.whl (125 kB) Collecting
itsdangerous<2.0,>=0.24 Downloading
itsdangerous-1.1.0-py2.py3-none-any.whl (16 kB) Collecting MarkupSafe>=0.23 Downloading
MarkupSafe-1.1.1-cp27-cp27mu-manylinux1_x86_64.whl (24 kB) Installing
collected packages: click, Werkzeug, MarkupSafe, Jinja2, itsdangerous, flask,
redis Successfully
installed Jinja2-2.11.3 MarkupSafe-1.1.1 Werkzeug-1.0.1 click-7.1.2
flask-1.1.4 itsdangerous-1.1.0 redis-3.5.3 WARNING: You are
using pip version 20.0.2; however, version 20.3.4 is available. You should
consider upgrading via the '/usr/local/bin/python -m pip install --upgrade
pip' command. Removing
intermediate container 7b87d89ae826 ---> a3666a1982c3 Step 5/5 : CMD
python app.py ---> Running in 4ecf7d263b2e Removing
intermediate container 4ecf7d263b2e ---> c204f10c4a49 Successfully
built c204f10c4a49 Successfully
tagged docker_web:latest WARNING: Image
for service web was built because it did not already exist. To rebuild this
image you must use `docker-compose build` or `docker-compose up --build`. Creating redis
... done Creating python
... done Attaching to
redis, python redis | 1:C 08 Jul 2021 09:32:36.218 #
oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo redis | 1:C 08 Jul 2021 09:32:36.218 #
Redis version=6.2.4, bits=64, commit=00000000, modified=0, pid=1, just
started redis | 1:C 08 Jul 2021 09:32:36.218 #
Warning: no config file specified, using the default config. In order to
specify a config file use redis-server /path/to/redis.conf redis | 1:M 08 Jul 2021 09:32:36.219 *
monotonic clock: POSIX clock_gettime redis | 1:M 08 Jul 2021 09:32:36.219 *
Running mode=standalone, port=6379. redis | 1:M 08 Jul 2021 09:32:36.219 #
WARNING: The TCP backlog setting of 511 cannot be enforced because
/proc/sys/net/core/somaxconn is set to the lower value of 128. redis | 1:M 08 Jul 2021 09:32:36.219 #
Server initialized redis | 1:M 08 Jul 2021 09:32:36.219 #
WARNING overcommit_memory is set to 0! Background save may fail under low
memory condition. To fix this issue add 'vm.overcommit_memory = 1' to
/etc/sysctl.conf and then reboot or run the command 'sysctl
vm.overcommit_memory=1' for this to take effect. redis | 1:M 08 Jul 2021 09:32:36.220 *
Ready to accept connections python |
* Serving Flask app "app" (lazy loading) python | * Environment: production python |
WARNING: This is a development server. Do not use it in a production
deployment. python |
Use a production WSGI server instead. python |
* Debug mode: on python |
* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit) python |
* Restarting with stat python |
* Debugger is active! python |
* Debugger PIN: 807-031-747 |
|
[root@stapp02
~]# docker ps CONTAINER
ID IMAGE COMMAND CREATED STATUS PORTS NAMES 70bcaadc42e7 docker_web "/bin/sh -c 'python
…" About a minute ago Up About a minute 0.0.0.0:5000->5000/tcp python 8d4817854d52 redis "docker-entrypoint.s…" About a minute ago Up About a minute 6379/tcp redis [root@stapp02
~]# |
|
[root@stapp02
~]# curl -ik http://localhost:5000 HTTP/1.0 200 OK Content-Type:
text/html; charset=utf-8 Content-Length:
50 Server:
Werkzeug/1.0.1 Python/2.7.18 Date: Thu, 08
Jul 2021 09:35:04 GMT This Compose/Flask demo has been viewed 1 time(s). [root@stapp02
~]# |
Happy Learning!!!!
0 Comments