Started using Docker yet? Here are some tips on writing dockerfile for your application.
While may be obvious to docker experts, these tips might help you avoid common issues.
FROM ubuntu:16.04 RUN apt-get update RUN apt-get install node RUN apt-get install npm RUN apt-get install curl
Apt-get would be the most used command in all docker files command. While the above
dockerfile looks fine, it has a couple of issues.
- apt-get update and apt-get install’s are on different lines, which would lead to caching of apt-get update command. Read more on docker build cache.
- Each of the RUN statements creates a layer in docker image, this leads to a bulkier image, try clubbing RUN commands logically.
A Better build would start like –
FROM ubuntu:16.04 RUN apt-get update && apt-get install -y curl \ node\ npm