Docker is a great tool for building and shipping Software. Many teams around the world are taking advantages of its features. For Development, it is particularly useful to be able to declare your whole stack in a docker-compose.yml
file and bringing it up and down with all the dependencies and packages that it needs to run.
I tend to use Docker a lot, not only as part of a project but also to perform several ad-hoc tasks. The primary benefit for me is that I don't have to bother installing and then removing the required software - a Docker image is all that's needed to spin-up a container! Here's the top list of Docker images that I tend to use ad-hoc.
1.Adminer
Adminer (formerly phpMinAdmin) is a full-featured database management tool written in PHP. It comes very handily when you need to access an external Database and having a UI will be of help.
Docker command:
docker run -d -p 8080:8080 adminer
Explanation:
-p 8080:8080 = link the host port 8080 with the container port 8080.
-d = run on detached mode.
2.Nginx
Nginx is a high-performance Web server and the go-to solution for multiple companies around the world. If you've ever had to configure it then you may appreciate being able to do it in your machine, rather than having to connect to the host where it is running.
Docker command:
docker run -it -p 80:80 -v $(pwd):/usr/share/nginx/html nginx bash
Explanation:
-p 80:80 = link the host port 80 with the container port 80.
-it = It is actually combining two flags, -i (interactive) and -t (allocate a tty).
-v = mount in volumen. $(pwd) is the current working directory and /usr/share/nginx/html is the place inside the container where it will be mounted.
nginx bash = run bash inside nginx (Inside the container you can run nginx commands as much as you want).
3.Ansible
Ansible is an automation tool for apps and IT infrastructure. It is like Chef and Puppet. You tell Ansible how to connect to the host and define how the host should be configured, and it will go to configure the host for you.
Docker command:
docker run -it -v $(pwd):/app ansible bash
Explanation:
-it = It is actually combining two flags, -i (interactive) and -t (allocate a tty).
-v = mount in volumen. $(pwd) is the current working directory and /app is the place inside the container where it will be mounted.
ansible bash = run bash inside ansible (Inside the container you can run ansible commands as much as you want).
4.Sqlite3
SQLite is a C-language library that implements a small, fast, self-contained, high-reliability, full-featured, SQL database engine. The data can be stored either on a single file in the disk or in-memory.
I've been using sqlite3 a lot lately to interact with a Python webscrapper that have the data in an SQLite file. The CLI and the instructions could get better, but definitively does the job!
Docker command:
docker run -it -v $(pwd):/root/db --entrypoint bash nouchka/sqlite3
Explanation:
-it = It is actually combining two flags, -i (interactive) and -t (allocate a tty).
-v = mount in volumen. $(pwd) is the current working directory and /root/db is the place inside the container where it will be mounted.
--entrypoint = sets the entrypoint command of the container. In this case, the entrypoint will be Bash.
Notes about the docker run commands:
- You can add
--rm
and it will remove the container as soon as it stops.
These are the ones that I tend to use nowadays. Of course, I also use ad-hoc images when I'm learning something (latest were Python3 and Elixir/Phoenix) or under other circumstances (checking if I'm ready for Node V10 or giving maintenance to an old PHP5.4 app).
Of course, if you're running an ad-hoc container a lot for one specific project, you may want to consider using docker-compose
instead.
Do you usead-hoc images in your day-to-day? Which ones?
Top comments (1)
Great, using docker ad-hoc is really great. I already either use git in this way.
Like this is possible use git normally.
git pull origin master
git checkout -b
Exists some drawbacks, but is useful and work well.
A lot of options really.