Understanding Docker Deeper

Posted on March 19, 2019


I’ve been using Dockerfiles and docker-compose for the past year now. And after awhile, you start to really understand what a container is. And what makes the concept of container’s special.

But, this video really cracked the code for me:

Basically, in the presentation, the speaker builds a “container” from scratch and shows off some of the features of ubuntu namespaces that allow Docker to exist.

Setting Up MultiSite Proxies With Ngnix

After I understood this, I took this complete “everything you’d ever need” setup from Laradoc, and built a dev enviroment to run everything you’d need to run at my workplace.

This means one ngnix container proxies all calls from various urls to different apps on the backend.

Executing Bash Commands

The biggest thing for deeply understanding docker for me was executing bash commands inside of the container.

If you’re using docker-compose, this looks something like docker-compose exec your_workspace_name bash. And if you are just using Dockerfiles it looks like docker exec. Read more here.

Once inside the container, you can run node -v or go version. It will output the version you used for your Dockerfile.

You can then exit, and run the same node -v or go version command again. Now, it’ll output the version of the language installed on your machine globally.

For me, this was a huge break through. I realized I could start running linux commands like apt-get install package or apt-get update and it’d install things on my Docker container. If this was something I needed everytime, I could include these commmands in the Dockerfile itself to run them everytime the container was built.