Docker Tricks and Tips

Choose Debian as the base image.

Choose the same base image for all your own images.

Build images for each step.

Put your important data at the host instead of the container.

Be very careful with the image whose Dockerfile has VOLUME.

You can run docker without sudo.

# Add theuser to docker group to run docker as a non-root user
# MUST logout and re-login to let it effective
usermod -aG docker theuser

Delete the unnecessary files in the Dockerfile to save disk space.

FROM myredisclient
RUN apt-get update \
&& apt-get install -y wget \
&& echo 'deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main' >> /etc/apt/sources.list.d/pgdg.list \
&& wget --no-check-certificate --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& apt-get update \
&& apt-get install -y --force-yes postgresql-client \
&& apt-get clean \
&& apt-get autoremove \
&& rm -rf /var/lib/apt/lists/*

--

--

--

iOS/Android/Web developer. UX engineering lead at Grab. Singapore/Hong Kong/Shanghai

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aijin Yuan (Vince)

Aijin Yuan (Vince)

iOS/Android/Web developer. UX engineering lead at Grab. Singapore/Hong Kong/Shanghai

More from Medium

Avoiding CI/CD dependency conflicts by using Containers

Devops Container Orchestration Using the Docker Swarm Model

Devops Container Orchestration Using the Docker Swarm Model

Docker Networks

GitLab CI CD Pipeline Tutorial