简体   繁体   中英

How to use CMD in Dockerfile for a command that contains flag?

How can I write the following command that contains a flag named --checkpoint using CMD in Dockerfile?

python3 --checkpoint /usr/src/app/logs-tacotron/model.ckpt-92000 /usr/src/app/demo_server.py

demo_server.py:

import argparse

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--checkpoint', required=True)
    args = parser.parse_args()
    print(args.checkpoint)

Thanks in advance.

Use this same format with flags also:

CMD ["executable","param1","param2"]

In your case:

CMD [ "python3", "--checkpoint", "/usr/src/app/logs-tacotron/model.ckpt-92000", "/usr/src/app/demo_server.py" ]

I tried:

CMD [ "ping", "-c", "2", "8.8.8.8" ]

and It worked!!

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