As previous post, I will elaborate about Cloud Native Applications. But before that, I will post some basic concepts about Docker as the Container technology for Cloud Native Applications approach.
Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications. By taking advantage of Docker’s methodologies for shipping, testing, and deploying code quickly, you can significantly reduce the delay between writing code and running it in production.
If you are still confused about description of Docker, Microservices, Cloud Native Applications technology means. You can read it in here: https://bicarait.com/2016/05/31/microservices-cloud-native-applications/
In this post, I will start with the basic on how to run your first application in Docker that will be provisioned in your Mac laptop. Then, I will do that also in vSphere Integrated Container and also VMware Photon Platform.
Let’s Start the first Chapter: INSTALLATION
- Download your Docker Engine from this URL (stable version): Get Docker for Mac (stable)
- Actually there are two approach to run docker on your Mac. The 1st one is to utilise Docker for Mac (which we will do this), and the second one is to utilise Docker Toolbox. The difference is in Docker for Mac approach, we will utilise HyperKit as lightweight virtualisation technology to run the container. Docker Toolbox will utilise Virtualbox as the virtualisation technology.
- Actually you can run both Docker for Mac and Docker Toolbox approach at the same time in your MacOS, but there are several things that you need to do, such as create different environment (set and unset command). I will not elaborate that in this post.
- Assume that your machine is empty for Docker engine.
- Install and Run Docker. Double click Docker.img that you have downloaded earlier to start the installation.
- Check Docker version that is now running on your Mac after the installation is completed.
- Let’s start with your basic application. Let’s do nginx web server using docker.
- Check your http://localhost first to check the status.
- Basically, docker will try to run the source of your application locally. But if docker can not find it, then it will search through the public repository (default configuration is docker hub).
- Check your http://localhost now to check the status.
- Check the status of the docker using
docker pscommand. If you want to stop the web server, do
docker stop webserverand start the web by
docker start webserver
- If you want to stop and remove the container, use the command
docker rm -f webserver. If you want to delete the local images do the command
docker rmi nginx. But before that, you can list the local images using
- If you want to use another docker repository other than https://hub.docker.com or do a file sharing from your Mac to your docker engine, you can also configure that in the Docker for Mac menu.
Let’s Continue with the second Chapter: BOARDING YOUR APPS
For this example we will utilise Docker Compose to run WordPress in an isolated environment. Compose is a docker tool for running multi containers environment. We will create a compose file, and then execute the YAML file using docker-compose command.
- Create a directory for the project in your Mac.
- Create a docker compose file. This will include wordpress and mysql to create a simple blog website.
- Now, build the project using the command $ docker-compose up -d
- Check whether the images already installed and run. Using docker images and docker ps command.
- Finally, test to open the wordpress in your browser. Because we put the configuration in port 8000, then we will open http://localhost:8000
- Do the installations of wordpress using the UI wizard, then finally open the created site.