2020-03-06 19:25:16 +01:00
## Compose sample application
2022-09-01 11:39:33 -05:00
### Use with Docker Development Environments
You can open this sample in the Dev Environments feature of Docker Desktop version 4.12 or later.
[Open in Docker Dev Environments <img src="../open_in_new.svg" alt="Open in Docker Dev Environments" align="top"/> ](https://open.docker.com/dashboard/dev-envs?url=https://github.com/docker/awesome-compose/tree/master/vuejs )
2020-03-06 19:25:16 +01:00
### VueJS
Project structure:
```
.
2022-05-10 11:59:25 +02:00
├── compose.yaml
2020-03-06 19:25:16 +01:00
├── README.md
└── vuejs
├── Dockerfile
└── ...
```
2022-05-10 11:59:25 +02:00
[_compose.yaml_ ](compose.yaml )
2020-03-06 19:25:16 +01:00
```
services:
web:
build: vuejs
ports:
- 80:8080
volumes:
- ./vuejs:/project
- /project/node_modules
```
2021-11-15 21:27:40 +01:00
The compose file defines an application with one service `vuejs` .
2022-05-10 11:59:25 +02:00
When deploying the application, docker compose maps port 8080 of the web service container to port 8080 of the host as specified in the file.
2020-03-24 17:00:41 +01:00
Make sure port 8080 on the host is not already being in use.
2020-03-06 19:25:16 +01:00
2022-05-10 11:59:25 +02:00
## Deploy with docker compose
2020-03-06 19:25:16 +01:00
```
2022-05-10 11:59:25 +02:00
$ docker compose up -d
2020-03-06 19:25:16 +01:00
Creating network "vuejs_default" with the default driver
Building web
2020-03-24 17:00:41 +01:00
Step 1/8 : FROM node:13.10.1-alpine
2020-03-06 19:25:16 +01:00
...
Successfully tagged vuejs_web:latest
WARNING: Image for service web was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build` .
Creating vuejs_web_1 ... done
```
## Expected result
2020-07-27 22:22:17 -05:00
Listing containers must show one container running and the port mapping as below:
2020-03-06 19:25:16 +01:00
```
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
701c02bb97b1 vuejs_web "docker-entrypoint.s…" 49 seconds ago Up 46 seconds 0.0.0.0:80->8080/tcp vuejs_web_1
```
After the application starts, navigate to `http://localhost:80` in your web browser.

Stop and remove the containers
```
2022-05-10 11:59:25 +02:00
$ docker compose down
2020-03-06 19:25:16 +01:00
Stopping vuejs_web_1 ... done
Removing vuejs_web_1 ... done
Removing network vuejs_default
```