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.
docker run -d -p 8080:8080 adminer
-p 8080:8080 = link the host port 8080 with the container port 8080. -d = run on detached mode.
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 run -it -p 80:80 -v $(pwd):/usr/share/nginx/html nginx bash
-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).
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 run -it -v $(pwd):/app ansible bash
-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).
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 run -it -v $(pwd):/root/db --entrypoint bash nouchka/sqlite3
-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
--rmand 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
Do you usead-hoc images in your day-to-day? Which ones?