Running the Docker container
There are a number of options for doing this, depending on security requirements, preferences, etc. Here are a few options:
When finished, you can then run
docker logs -f learning-lab to trail the logs of the running application, to ensure that it has started successfully.
docker create and
You can create a Docker container without running it, then copy a
.env file defining your environment variables into the container. Then start the container's default command by running
docker start <container>.
# Create the container, but don't start it yet
docker create --name learning-lab \
--restart unless-stopped \
-p 3000:3000 \
# Copy the .env file from the host into the container
docker cp .env learning-lab:/usr/src/learning-lab/.env
# Start the container
docker start learning-lab
This is the recommended path because it securely stores your environment variables without exposing them in
docker inspect, while still providing all the necessary information.
--env-file flag in
You can use the
--env-file flag to run the Docker image with a
.env file included. Note that this may expose your container's environment variables to external services that run
docker inspect on your container.
$ docker run --env-file .env learning-lab
-e flag to add them one-by-one in
By using the
-e flag in your
docker run command, you can inject each environment variable:
$ docker run -e APP_ID=1 -e WEBHOOK_SECRET=shhhimasecret learning-lab