Your first php application inside a Docker container in 15 minutes (Part 2)

Lets create the container

In part 1 of this blog post we looked briefly at how the docker technology works. I also promised there won’t be any more blabber and that we will be getting our hands dirty.

The first step, unless you have already done so, it to install docker on your local machine. Head over to https://www.docker.com/get-started and install the appropriate version for your operating system.

Secondly, go ahead and clone this git repo to a local folder.

Thirdly, change directory to docker (cd docker) inside the repo you just cloned, and execute the command

docker-compose up --build

If you installed everything correctly, the docker compose command should start “compiling” the instructions inside the file “docker/Dockerfile”. We will get to that in a minute, but in the mean time, go grab a coffee, while you wait for the container to be created. This can take anywhere from 5 to 20 minutes, depending on the machine you are running the command on and your internet connection. Subsequent container rebuilds will take much less time since the data fetched from the internet will be cached.

Once the process is done, you should see something like this in your terminal :

| 2019-03-01 18:46:57,504 INFO spawned: 'sshd' with pid 1040 docker-ssh-lamp    | 2019-03-01 18:46:58,506 INFO success: sshd entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

At this stage the container is up and running, and you can confirm this by pointing your browser to http://localhost:2080. If all went well, you should see something like this in your browser :

You can also ssh inside the container on port 2022, using root as username and “123456” as password, unless you were already feeling adventurous and have modified the variables inside the Docker file.

So, how did all this magic happen in just 5 (or 15) minutes ??

Stay tuned for Part 3, where we take a closer look at how everything came together.

Leave a reply:

Your email address will not be published.

Site Footer