Sagi Mann
Sagi Mann

Reputation: 3610

Possible to override docker environment variable at build time?

I'm new to Docker and am trying to setup my own image based on sinet/nginx-node. Its Dockerfile, as described on Docker Hub, contains:

ENV NODE_VERSION 5.9.1

My own Dockerfile starts with:

FROM sinet/nginx-node

Is it somehow possible to override the NODE_VERSION variable at build time, so that my image will get built based on a newer version of Node? Or should I simply avoid using the original sinet/nginx-node and simply make my own modified copy of their Dockerfile, including a newer Node version?

Upvotes: 0

Views: 205

Answers (1)

k0pernikus
k0pernikus

Reputation: 66500

By using sinet/nginx-node you are using that as your base layer. Docker won't rebuild the base layer, and while you can change the ENV variable, it won't rebuild your base image.

Docker is about having well-defined snapshots of a state, so for your use case I would opt for creating your own Dockerfile with the ugraded node version.

You also could try upgrading node within your current Dockerfile.

Upvotes: 1

Related Questions