1

I am an absolute beginner on this.

I need to run two containers, with two separate apps. One of them should run a script (which runs npm start and not much else), but that might not be possible?

Dockerfile

FROM node:14.16.0-buster
RUN apt-get update && apt-get install -y libsecret-1-dev groff less bash-completion && rm -rf /var/lib/apt/lists/*
ENV npm_config_user root
COPY startscript.sh /usr/local/bin
RUN chmod +x /usr/local/bin/startscript.sh
ENTRYPOINT []

And the docker-compose.yml

version: '3'

services:
    first-container:
        build:
            context: .
        ports:
            - '8080:8080' # node web interface
        env_file: .env
        command: bash -c "/usr/local/bin/startscript.sh"

    second-container:
        build:
            context: .
        ports:
        - '8181:8181' # node main app web interface

       # volumes:

 volumes:
    node-modules: # persist local node_modules

I can run the containers, but the script doesn't run automatically. Suggestions?

thanks

2
  • One thing I immediately notice is that the indentation is wrong, is your yaml file actually indented this way? The second-container block needs to go inwards. Commented Mar 28, 2021 at 18:20
  • no I think I messed up while copying here, but thanks!! Commented Mar 28, 2021 at 18:22

1 Answer 1

1

Just run with ENTRYPOINT ["npm","start"]

And you want to run 2 commands just create a script file script.sh

#!/bin/bash

npm start &

# Other command here

Then ENTRYPOINT ["/script.sh"]

Sign up to request clarification or add additional context in comments.

1 Comment

thank you, that would be the entrypoint for both containers though, correct? It might work for me but was wondering how to specify a different one for different containers.. thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.