# How to pass variables to a Docker container when building a Node app

DevFeed: [How to pass variables to a Docker container when building a Node app](<https://devfeed.tech/articles/how-to-pass-variables-to-a-docker-container-when-building-a-node-app-20736.md>)

Original publisher: [Read original article](<https://blog.fedecarg.com/2016/11/05/how-to-pass-variables-to-a-docker-container-when-building-a-node-app/>)

Author: Federico

Published: 2016-11-05T21:42:00Z

Content type: tutorial

Language: en

Sources: [Federico Cargnelutti](<https://devfeed.tech/sources/federico-cargnelutti.md>)

Topics: [Dockerfile](<https://devfeed.tech/topics/dockerfile.md>), [Environment Variables](<https://devfeed.tech/topics/environment-variables.md>), [Docker Image](<https://devfeed.tech/topics/docker-image.md>), [Command-line interface](<https://devfeed.tech/topics/cli.md>)

Tags: [command-line](<https://devfeed.tech/tags/command-line.md>), [docker](<https://devfeed.tech/tags/docker.md>), [docker-image](<https://devfeed.tech/tags/docker-image.md>), [environment-variables](<https://devfeed.tech/tags/environment-variables.md>), [http-server](<https://devfeed.tech/tags/http-server.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [linux](<https://devfeed.tech/tags/linux.md>), [node-js](<https://devfeed.tech/tags/node-js.md>), [npm](<https://devfeed.tech/tags/npm.md>), [open-source](<https://devfeed.tech/tags/open-source.md>), [port](<https://devfeed.tech/tags/port.md>), [programming](<https://devfeed.tech/tags/programming.md>)

## AI overview

A tutorial on passing variables to a Dockerized Node application during image builds and container execution. It explains Dockerfile ENV and ARG instructions, command-line build arguments, shell-based use of NODE_ENV, and exposing a port to start an HTTP server.

## Source excerpt

Environment variables are declared with the ENV statement and are notated in the Dockerfile either with $VARIABLE_NAME or ${VARIABLE_NAME}. Passing variables at build-time The ENV instruction sets the environment variable to the value. The environment variables set using ENV will persist when a container is run from the resulting image. For example: The Dockerfile allows you to specify arguments [...]