Skip to content

Docker Vue Only

WARNING

Please note that we do not provide Docker support for the Windows operating system.

Overview

Docker is a tool that allows you to package your application and its dependencies into a virtual container that can run on any Linux server. This provides a lightweight, isolated environment that can be easily replicated and shared. Docker containers are run from Docker images, which are built from a series of instructions contained within a Dockerfile. A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image. Using docker build, users can create an automated build that executes several command-line instructions in succession. This page describes how to build a Docker image for your application, and run it locally or in a cloud environment.

Prerequisites

Building a Docker image

You may refer to the official docs of Docker while building a Docker image:

To build a Docker image for your application, you need to create a Dockerfile. For your convenience, we have provided sample Dockerfiles for production and development environments.

Development

The Dockerfile suitable for development environments is located in the root directory of your project. It is named dev.Dockerfile. This file is used to build a Docker image that contains your application code and all the dependencies required to run your application. The image is based on the official Node.js image.

You can customize the dev.Dockerfile file according to your needs. You can build the image by running the following command:

sh
docker build -f dev.Dockerfile -t <image-name> .

Or you can create another Dockerfile (named Dockerfile) in the root directory of your project, copy the contents of dev.Dockerfile into it, and then run the following command:

sh
docker build -t <image-name> .

Production

The Dockerfile suitable for production environments is located in the root directory of your project. It is named prod.Dockerfile. This file is used to build a Docker image that contains your application code and all the dependencies required to run your application. The image is based on the official Node.js image.

You can customize the prod.Dockerfile file according to your needs. You can build the image by running the following command:

sh
docker build -f prod.Dockerfile -t <image-name> .

Or you can create another Dockerfile (named Dockerfile) in the root directory of your project, copy the contents of `prod.Dockerfile into it, and then run the following command:

sh
docker build -t <image-name> .

Running a Docker container

You may refer to the official docs of Docker while running a Docker container:

Development

Using Docker Compose

You may create a docker-compose.yml file in the root directory of your project to run the container easily. For your convenience, we have provided a sample docker-compose.dev.yml file for the development environment. You can customize the docker-compose.dev.yml file according to your needs. You can run the container by running the following command:

sh
docker compose -f docker-compose.dev.yml up -d

If you have created a docker-compose.yml file in the root directory of your project, you can run the container by running the following command:

sh
docker compose up -d

Without Docker Compose

After building a Docker image, you can run a Docker container based on that image. To run a Docker container, you can run the following command:

sh
docker run -d -p <host-port>:<container-port> --name <container-name> <image-name>

After your container is up and running, you can access your application at http://localhost:<host-port>.

Production

Using Docker Compose

You can find a docker-compose.prod.yml file in the root directory of your project to run the container easily. You need to customize the docker-compose.prod.yml file according to your needs. After updating your docker-compose.prod.yml file according to your needs, you can run the container by running the following command:

sh
docker compose -f docker-compose.prod.yml up -d

If you have created a docker-compose.yml file instead in the root directory of your project, you can run the container by running the following command:

sh
docker compose up -d

Without Docker Compose

After building a Docker image, you can run a Docker container based on that image. To run a Docker container, you can run the following command:

sh
docker run -d -p <host-port>:<container-port> --name <container-name> <image-name>

WARNING

We use Nginx in our Dockerfile to serve the production build in the production environment. Additionally, we have provided a basic nginx.conf file. You can modify this file according to your requirements, If you prefer, you can choose an alternative web server like Apache..

Stopping a Docker container

You may refer to the official docs of Docker on how to stop a Docker container:****

Using Docker Compose

To stop a Docker container, you can run the following command if you have created a docker-compose.yml file in the root directory of your project:

sh
docker compose down

The docker compose down command stops containers and removes containers, networks, volumes, and images created by docker compose up.

Without Docker Compose

To stop a Docker container, you can run the following command:

sh
docker stop <container-name>

Removing a Docker container

You may refer to this official doc on how to remove a Docker container.

To remove a Docker container, you can run the following command if you have not used the docker compose down command:

sh
docker rm <container-name>

Removing a Docker image

You may refer to this official doc on how to remove a Docker image.

To remove a Docker image, you can run the following command:

sh
docker rmi <image-name>

Running a command in a Docker container

You may refer to this official doc on how to run a command in a Docker container.

To run a command in a Docker container, you can run the following command:

sh
docker exec -it <container-name> <command>