Local Web Development Setup with Docker
Every Tinkerer Needs Their Tools
A developer has an ever-growing toolkit, let’s build the tool box. Countless “support” services are often incorporated into web development projects. It becomes a pain to start up a local MySQL instances and the like every time you boot up. It only becomes more of an issue as you begin to develop and test more services. At a corporate level you may be given a server with each service you will use wrapped up neatly to data dump to your hearts content, but many of us need to fiddle at home. For this I use a docker-compose configuration where I can easily deploy my entire supporting cast with a quick CLI command. Let’s get into it.
The Services
In typical fashion, I am prepared to start you off with some services I frequent. These would be Redis, RabbitMQ and MySql. To develop on these services and test they are up and running, you will need the following:
- Redis-tools: Install with
sudo apt-get redis-toolsor mac with homebrewbrew install redis - I will use DBeaver to connect to the MySQL instance, though this can be done in the CLI.
- Docker-Hub: You need to start docker on your machine, an easy way to do this is to run docker-hub desktop.
The Config
This is where the magic🧙 Happens! This config will pull the given images from docker hub and deploy them to the given ports locally, then we can connect away! Note the “volumes” section of each service, which references a “docker-conf” folder in the same directory as the config. This is extremely important, it ties the storage for each service container to a location outside the container. This way the data saved to these services will persist when the container is closed.
Deployment and Testing
With this config you need only a bit more magic to begin interacting with these services. With this command you will spin up containers built from the provided images docker-compose -f docker-toolkit.yml up -d, here the -d switch detaches the command so it will run in the background (and you can continue to use this terminal).
Get Ken Foss’s stories in your inbox
Join Medium for free to get updates from this writer.
Now that the services are up we can use them… let’s get on it.
Redis
- Connect to the service:
redis-cli -h localhost -p 6379 - Create a key-value pair:
set newkey “Hello World” - Visualize the key:
keys * - Get the corresponding value:
get newkey
RabbitMQ
- Navigate to the following url: http://localhost:15672/
- Enter username and password as “admin”
MySql
My MySql settings are as follows in DBeaver, the password is “root”.
Now, I am going to create a table called “test”, I want to ensure it persists when the container is restarted.
Success! Upon restarting of the container our table is there just how we created it.
Restarting Your Containers
There is no need to run the docker-compose every time you start these services. The containers persist even as you restart your machine. If we go into docker desktop we can see these services and restart them.
Now, you can restart these containers with the “play” button. If you prefer CLI commands the following will show your available containers:
docker ps -aAnd start a container of your choosing:
docker start my_container_name










