Introduction to Docker Day 6 (Final)
For the final day on Introduction to Docker, we will build a docker image. we can use the exercise on day 5 to finalize the installation process. Next, we create a text file and name the file as Dockerfile. This is the build file for a docker image. It has to be name as Dockerfile.
Build Docker Image
The format of the Dockerfile is as follows:
# our base image
FROM ubuntu
# Install python and pip
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y octave
# run the application
CMD ["octave"]
We use ubuntu as our base os and we run updates and install octave. The command to run the app will be octave. You can also checkout the sample Dockerfile at Github. https://github.com/technozeal/dockerfilesample
The command to build the app will be as follows:
docker build -t username/mynameofapp .
We can test the image using docker run command.
Upload Docker Image
Once we are satisfy with the build we can push the image to the docker public repository. Once you have created an account with docker, you can upload images.
Ue the following command to login
docker login
After login is successful, use the command below to push the image to the server
docker push <image>
Final Note
Please note that this basic introduction is just a small portion of what docker is about. The power of docker is deploying app in swarm nodes. For further details please checkout the documentation site here.
***
Comments
Post a Comment