简体   繁体   中英

Why does the ENTRYPOINT log output but not the CMD or RUN in Dockerfile

In this Dockerfile i have an ENTRYPOINT that calls a script that simply logs an echo "testing". This output works locally when I build and run the Dockerfile. It also logs to cloudwatch when I use in conjunction with a docker-compose for aws.

However the RUN and CMD commands do not output anything to the console or cloudwatch, how do i see their output? I would expect at least some errors

ENTRYPOINT bash -c "/migrate.sh"

WORKDIR /
RUN yarn
CMD ["yarn migration:run", "dist/src/main"]

I'm building just with docker build -t test:test . then docker run <imagename>

The RUN statement in the Dockerfile is only invoked when you build the container (at which point you should see the output of yarn in this case). When you docker run the container it will just execute the ENTRYPOINT and/or CMD (in this case the output of the ENTRYPOINT as there is no CMD)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM