Note: All installation instructions are specific to
[Amazon Linux 2 AMI (HVM), SSD Volume Type - ami-01720b5f421cf0179 (64-bit x86) / ami-04c2a5c7e6c051fb2 (64-bit Arm)]
-
Prerequisite
- Running EC2 instance
[Amazon Linux 2 AMI (HVM), SSD Volume Type - ami-01720b5f421cf0179 (64-bit x86) / ami-04c2a5c7e6c051fb2 (64-bit Arm)]
- Security groups having
SSH permission
- Security groups having
5000 port open
for docker-compose demo
- Running EC2 instance
-
Install Docker
>`sudo yum update -y` >`sudo amazon-linux-extras install docker`
Note: Please refer the below link for more details: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-basics.html
-
Install Docker-Compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
-
Install python 3
>`sudo yum install python3`
Note: python3 is required to run the program.
-
Change Permission of Docker-Compose:
>`sudo chmod +x /usr/local/bin/docker-compose`
-
Configure Docker Service:
-
Start the Docker service
>`sudo service docker start`
-
Add the
ec2-user
to thedocker
group so you can execute Docker commands without usingsudo
.>`sudo usermod -a -G docker ec2-user`
-
Enable Docker Service
>`sudo systemctl enable docker.service`
Note:
- Log out and log back in again to pick up the new
docker
group permissions. You can accomplish this by closing your current SSH terminal window and reconnecting to your instance in a new one. Your new SSH session will have the appropriatedocker
group permissions.
- Verify that the
ec2-user
can run Docker commands withoutsudo
.
docker info
-
-
config.py
ClassBelow are the config parameter defined in
config.py
class.- DOCKERIZE_PY_APP_PATH (default
'./DOCKERIZE_PY_APP/'
) - DOCKERIZE_PY_APP_FILE (default
'app.py'[3.8 version]
) - DOCKERIZE_PY2_APP_FILE (default
'app2.py'[2.7 version]
) - DOCKER_COMPOSE_APP_PATH (default
'./DOCKER_COMPOSE_DEMO_APP/'
) - DOCKER_FILE_TEMPLATE (template for creating docker file)
- DOCKERIZE_PY_APP_PATH (default
-
Copy
DOCKER_CLI
and runrequirements.txt
- Copy the
DOCKER_CLI
from local to Docker node using winscp or any other tool. - Go to root dir
DOCKER_CLI
- Run below command
>
sudo python3 -m pip install -r requirements.txt
- Copy the
-
Run Docker-CLI program
Note: Do the
SSH
to Docker Node-
Go to root dir
DOCKER_CLI
-
Run below command
>`python3 DockerCli.py`
-
Press-1
for navigate toDocker Basic Operations
Menu.
Press-2
for navigate toContainerize a Python Program
Menu.
Press-3
for navigate toDocker Compose Demo
Menu.
Press-4
for navigate toSetting
Menu.
Press-5
for Exit.
Press-1
List all containers.
Press-2
Run a container[detach Mode].
Press-3
Stop containers.
Press-4
Remove stopped/exited containers.
Press-5
Go Back.
Press-1
Containerize and Run a Python Program.
Press-2
Run a Python Program.
Press-3
Go Back.
Press-1
Run Docker Compose Demo.
Press-2
Go Back.
Press-1
for disabling the color menu. (defaultenable
)
Press-2
for enable color menu after disabling.
Press-3
for display "Docker Client Info" in Main Menu.(defaultdisplay
)
Press-4
for hiding "Docker Client Info" in Main Menu.
Press-5
Go Back.
- For Docker Compose i have taken the reference from below link and modified(Added new containers) for demo. https://github.com/arsenidze/microservice_application
- Docker-Compose APP Details:
- After
Docker-Compose Demo
run successfully.App can be open in browser usingDocker AMI public IP
http://Public_IP_of_Docker_Node:5000