Posts

Showing posts with the label docker image

Introduction to Docker Series

We have written a series of posts introducing the basics of docker. We focus on working with docker and creating image. We did not cover scalable deployment using docker. Please refer to the following post: Introduction to Docker - Day 1 Introduction to Docker - Day 2 Introduction to Docker - Day 3 Introduction to Docker - Day 4 Introduction to Docker Day 5 Introduction to Docker Day 6 (Final) ***

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 re...

Introduction to Docker Day 5

Image
On day 5, we will focus on running base OS such as ubuntu, CentOS and Alpine. We will also learn how to reuse exited container. Finally, we will learn how to convert the container into images. Running Base OS To run base OS in a container, use one of the following command: docker run --name ubuntuwithpython3 -it ubuntu Next, we would like to perform system update and then install Python3 using the following command: apt-get update apt-get upgrade apt-get install python3 exit We can explore various base os. Base os are the os which the docker image is build on. Many OS vendor are racing to build the base os with the smallest size. docker run -it ubuntu docker run -it centos docker run -it debian docker run -it alpine docker run -it busybox docker run -it fedora /bin/bash Most OS will default to shell. however, for Fedora we must specify the shell path. Exit the base OS when done. Continue Exited Container In the last section, we have install Pyth...

Introduction to Docker - Day 4

On day 4, we will learn how to manage and clean up containers. Then we will learn how to create common folder to be use in docker container. Docker Container Management Listed below are many command that can be used to manage containers. For some function, there are more than one command/method to perform the task. To list down all container that are active using the command: docker container ls To list down all container including non-active containers, use the command docker container ls -a To stop an active container docker container stop <container_name> docker container kill <container_name> docker stop <container_name> docker kill <container_name> To remove container docker container rm <container_name> docker rm <container_name> To remove all inactive container docker rm $(docker ps -aq) docker container prune Sharing Folder with Containers We can create a common folder to be used as data du...

Introduction to Docker - Day 3

Image
On Day 3, we will learn more about running docker app and various options.  Running Docker Image To run a docker image, the basic syntax is as follows: docker run <image_name>  Basic syntax is only able to run hello-world properly. For other apps, we need additional options. To run a docker image with optional container name use the syntax: docker run --name <container_name> <image_name> Example: docker run --name someName hello-world Run Interactive Docker App To run an interactive app we use the following command: docker run -i -t --name <container_name> <image_name> <command_in_app> -i is for interactive session -t is to create a tty for user interaction Usually we use -it we can append additional command to be executed in the app. The command should be appended after the image name Example: docker run -it --name myubuntu ubuntu We perform any task such just like a virtua...

Introduction to Docker - Day 2

Image
For second day of Introduction to Docker, we will learn how to run the docker test app with name option. After that, we discuss about pulling an actual docker application and we will learn the naming convention of docker image. Run with Name Option We start by running hello-world app without any option. Run the test app as follows: docker run hello-world List the container: docker container ls -a The result should be as follows: We then remove the container using the ID or the name cranky_brahmagupta . This name is created randomly by the system if we failed to supply a name. Now, we remove the container as follows: docker rm cranky_brahmagupta To run the container and supply a name, we use the option --name follow by a single space and the custom name. See example below: docker run --name simple hello-world List the container docker container ls -a The result is as follows: Please note that the name of the container will be the name that ...

Introduction to Docker - Day 1

Image
This is a basic introduction to Docker for Mac. Before we starts to understand Docker, we must know about virtual machine. Readers for this blog is familiar with VirtualBox and Parallel. Recently, we are testing various new Linux distribution via virtual machine. So far we have installed more than 10 different flavor of Linux distribution. It takes up more than 80GB of hard disk space.  Since, a lot of them are different flavor of Debian/Ubuntu distribution, there are a lot of repetitive installation. We are not going to show the standard layered chart. If you preferred the official layered chart, please check out the tutorial from docker. The chart below is an example of what happened to by Macbook Pro. Linux App Linux App Linux App Linux App Linux App Linux App Antergos FreeBSD Manjaro Ubuntu Elementary MX Linux App App VirtualBox Parallel Mac OS X Macbook Pro Hardware If we use Docker, then we can dispense with installing different flavor of Linux. We can still hav...