Build a Boto3 Development Environment using Docker

Darius M
4 min readMar 11, 2023

--

What is Docker?

Docker is an open platform that allows you to build, test, and deploy applications quickly. Docker enables you to separate your applications from your infrastructure. In doing so, not only does it enable you to deliver software quickly it also allows you a degree of certainty in regards to the environment an application needs to run. You can be certain that regardless of where you run this application it will work. Thus solving the issue of “it works on my machine”.

Prerequisites

This walk through assumes some prior knowledge in Docker. If you have none please watch this first and come back.

Objective

  • Build docker file for Boto3 / Python
  • Use either the Ubuntu or Python official images on Dockerhub
  • Download any three repos to local host
  • Create three containers using the image you created
  • Each container should have a bind mount to one of the repo directories
  • Log into each container and verify access to each repo directory

supplementary information

Bind mounts

A bind mount is just a mapping of the host files, or directories, into a container file or directory. So you can either specify a directory or a single file. You can really map anything you want from the host into the container.

Dockerfile

A Dockerfile is a similar to a script in concept except it’s far more all encompassing. Using a Dockerfile you can automate the process of downloading and creating images. Attaching necessary infrastructure and dependencies in single For more info on the format of a Dockerfile checkout the DockerHub.

Images

An image can be defined in a few ways, but for our purposes it’s best to think of a docker image like a template. It’s an immutable read-only template that defines how a container will be realized.

Containers

It would be best to think of containers as processes. A container is not a VM. It’s far more bare-bones. A container is a heavily manicured process that runs inside our host machine.

Building our Dockerfile

Im first going create a new local directory and create the Dockerfile within that.

Each Dockerfile you make will be different depending on the image you are trying to build or create. Here we are downloading the most recent official python image using the FROM keyword, running an install command so we can install boto3 using the RUN keyword and the “python” string will also execute, though to be honest we don’t need it for our purposes and you will see why.

The next step is to run.

docker build -t bototest .

Our image will take a little time to build.

Next we will download our 3 Github repo’s using the git clone command

git clone http://repo.git

Once our repos have been cloned to our local machine we can create our containers and attach bind mounts. This will be done in a single command.

docker container run -d -v $(pwd):/repo image sleep 1000

This spends up our first container using the image we created, we have all attached our local repo to our container. Which means we can now access that repo in our container. We check this with the exec command and the container ID.

We repeat this process with our other repositories making sure to validate in the same way. Once we have confirmed that our repositories are in fact attached to the containers we have compete our task.

This concludes our walkthrough, make sure to subscribe for more Tech Tips.

--

--

Darius M

Cloud Engineer ☁️ IT Specialist| Linux | Dev Ops Enthusiast Nerdy about all things self improvement and Crypto.