Tips for New Docker Users
By
Anais Dotis-Georgiou /
Use Cases, Developer
Aug 07, 2018
Navigate to:
This post has been written to accompany the post “Applying Machine Learning Models to InfluxDB with Loud ML & Docker for Time Series Predictions” for readers who are new to Docker.
I tend to start projects with an overly optimistic expectation of how “easy” it will be to accomplish them. This is probably the result of working alongside incredibly knowledgeable and supportive people who make me feel that anything is possible. I am new to Docker, and I thought using Docker was going to be a snap (shout out to @noahcrowley for patiently helping me). Turns out there’s a little bit of a learning curve. To help get you up to speed, I want to share the mistakes I made and how to avoid them.
<figcaption> What the cute Docker whale started to look like after the first day</figcaption>
Mistake One: Using docker container ls
to list running containers.
Tip: Why type more? Use docker ps
to list running containers and docker ps -a
to list every container.
Mistake Two: I create a container with the wrong configurations. I create a new container to fix my mistake. Repeat 10x. I finally successfully create a “good” container.
Tip: Use docker system prune
to remove all unused containers, networks, and images and get rid of the “bad containers”.
Tip: Name your containers with --name
to easily find your container.
Mistake Three: If you don’t specify a container name, Docker will auto generate a delightfully quirky container name for you like “flamboyant_kumbaya” or “funkadelic_oppasum”. Docker will also assign a CONTAINER ID like “d239a57b3730”. Unfortunately, I’m not very good at spelling or copy and pasting.
Tip: Call a docker container by the first 3 characters of the CONTAINER ID. For example, use docker rm d23
to remove one container.
Mistake Four: I didn’t assign a --name
to my container. I’m trying to connect this container to other containers over a user-defined bridge network with a static IP. Even though Docker gives every container a CONTAINER ID and NAME, neither is by default DNS-resolvable.
Tip: Assign a --name
to your container so that it is DNS-resolvable.
Mistake Five: I often assume that my containers are successfully connected to each other.
Tip: Use docker inspect $your_network
to see if your containers are connected. Also install ping with apt-get update apt-get install iputils-ping
and make sure that you can ping the rest of your in-network containers from one container.
Mistake Six: I would get this error when trying to bind certain directories to Docker:
The paths /var/folders/zz/... and /var/folders/zz/... are not shared from OS X and are not known to Docker. You can configure shared paths from Docker -> Preferences... -> File Sharing.
Tip: Use Docker’s file system sharing (osfx), add the path you need, and restart Docker.
<figcaption> What I hope Docker looks like to you as you begin your journey</figcaption>
I hope this tutorial helps get you started with Docker. If you have any questions, please post them on the community site or tweet us @InfluxDB.