Complete the command to start services in detached mode using Docker Compose.
docker-compose up -[1]The -d flag runs Docker Compose services in detached mode, allowing the terminal to be free.
Complete the command to rebuild services before starting them.
docker-compose up --[1]The --build option forces Docker Compose to build images before starting containers.
Fix the error in the command to watch file changes and restart services automatically.
docker-compose up -[1] --watchThe correct short flag for detached mode is -d. The long form is --detach, but --watch is not a valid Docker Compose flag.
Fill both blanks to create a service that watches for file changes and restarts automatically using a tool.
version: '3.8'\nservices:\n app:\n build: .\n command: [1] --watch [2] app.js\n volumes:\n - .:/app\n ports:\n - '3000:3000'\n
nodemon is a tool that watches for file changes and restarts the Node.js app automatically. The --watch flag tells nodemon which files or folders to watch.
Fill all three blanks to define a Docker Compose service that uses a volume, sets environment variables, and runs a watch command.
version: '3.8'\nservices:\n web:\n build: .\n volumes:\n - [1]:/usr/src/app\n environment:\n - NODE_ENV=[2]\n command: [3] --watch src\n ports:\n - '8080:8080'\n
The volume maps the local ./app folder to the container path. The environment variable NODE_ENV is set to development for dev mode. The command uses nodemon to watch the src folder for changes.