You are on page 1of 7

Docker

How to setup docker & run apps in docker


Setting up Docker in Ubuntu
• Refer the official documentation to setting up the environment
• https://docs.docker.com/install/linux/docker-ce/ubuntu/

• After the installation is complete, run the command docker --version


to check if the docker is installed successfully
Create a Project to Deploy
Here for the demo purpose, a python hello world project is created with its base URL
returning “Hello World” as response. The app is tested & working in local environment.
Now this needs to be deployed as a docker container.

Project : https://github.com/itsparser/code-tool

Following are the steps to create the docker image & run in a container
Structure/Files of the Project
The project mentioned in the previous slide contains the below listed files
• main.py -- Entry point for python application
• Dockerfile -- Docker file for building Ubuntu Image which contains the project code
• Dockerfile-runner -- Extending the ubuntu image generated in previous step & contains the
entrypoint for starting the project
• docker-compose.yml -- docker compose file which specifies the configuration for creating the
images using the above docker files
• requirements.txt -- requirements file contails the dependencies for project, used by the
Dockerfile while setting up the ubuntu environment
Building the Docker Image
• Execute the command “docker-compose build” to build the images
specified in the docker-compose.yml. [Note : If the file name is different
it needs to be externally specified like “****COMMAND HERE*****” ]
• Running the above command will first build the images which doesn't
have any dependency on other images being build parallely [here
testing/base] & then those images which depends on the previous
images will be build [here testing/service]
• The docker-compose.yml file contains the configuration with mapping
for the binding port in host machine with the ports in which the app
runs in the container
• So the command executed in the step 1 will build the image with
these configurations
• To start the application, execute the command “docker-compose up”
Thank You.

You might also like