This repository shows how you can build an image of your Nuxt app and create a container running it. Additionally, it shows how to handle env variables while building the image and running a container.
First of all make sure you have Docker installed.
To build an image run the following command in the project root.
docker build -t nuxt/docker-demo:latest .
This command builds an image following the specifications in the Dockerfile using the standard .env
file due to not excluding it.
Create and run a new container from the image you just build by running:
docker run -p 3000:3000 nuxt/docker-demo:latest
As long as you follow the naming conventions for the runtime config specified in the nuxt documentation you can do so as such:
docker run --env NUXT_PUBLIC_SOME_VALUE="hello there!" -p 3000:3000 nuxt/docker-demo:latest
or as such
docker run --env-file ./.env.run -p 3000:3000 nuxt/docker-demo:latest
You can list your images by running:
docker images
You can delete an image by running:
docker rmi <image_id>
You can list your containers by running:
docker ps -a
You can stop a containers by running:
docker stop <container_id>
You can list delete a container by running:
docker rm <container_id>