Sails - Start a Sails app on Docker using the docker run command
by
Jeremy Canfield |
Updated: August 02 2021
| Sails articles
This assumes you have created a Sails app on docker using the docker run command.
Let's say you have installed an app named foo-app, and the files for the app reside at /usr/local/apps/foo-app on your Docker server. Move into the dirctory.
cd /usr/local/apps/foo-app
Before you can start a Sails app on Docker using Docker Compose, you will need to install Docker Compose.
Create a YAML file named docker-compose.yml.
touch /usr/local/docker/sails/docker-compose.yml
Append the following to docker-compose.yml. Let's break this down.
AVOID TROUBLE
By default, in the container, the app will be located at /<app name>, such as /foo-app in this example. The volume option will need to point to /<app name>.
- The nodejs/sails:latest image is used
- The --volume option is used to define the directory on the Docker server (/usr/local/app) that will be mounted to a directory in the container (/foo-app).
- The --workdir option is used to define the directory on the Docker server (/foo-app) where the app will be created.
version: '3'
services:
api:
ports:
- '8080:1337'
volumes:
- /user/local/apps:/foo-app
working_dir: '/foo-app'
command: /bin/bash -c "sails lift --silly &"
Did you find this article helpful?
If so, consider buying me a coffee over at