How can I run multiple statements using json array format for Docker ENTRYPOINT?

I need to set ulimit and sysctl before starting my service, so I have been doing the following in my ENTRYPOINT:

ulimit -n 4096; sysctl -p; start_service

  • docker daemon restarting containers when not required to
  • Docker container DHCP like bridged VirtualBox
  • Mounting Azure File Storage in Docker container via Kubernetes
  • how to set docker_opts on windows
  • Using RSpec, Capyabra and Selenium (docker), on click method getting error: Connection refused
  • How to wait till POST request is finished in GO?
  • But it seems that if I want to use CMD as default arguments to ENTRYPOINT, I have to use the json array format.

    But I don’t know how to run multiple statements using the json array format.

  • what's the docker pattern of serving both static and dynamic content
  • Docker: coudn't expose a service
  • How to run docker daemon?
  • How do I expose a UDP Port on Docker?
  • How can I setup Docker container with individual IP address on EC2 instance?
  • Want to run docker in windows server 2016 on azure
  • One Solution collect form web for “How can I run multiple statements using json array format for Docker ENTRYPOINT?”

    Simplest way is probably to execute it as a script (here start_service is replaced with a simple echo for testing)

    $ cat start.sh
    #!/bin/bash
    ulimit -n 4096; sysctl -p; echo $@
    
    $ cat Dockerfile
    FROM ubuntu
    COPY . /tmp
    CMD ["test"]
    ENTRYPOINT ["/tmp/start.sh"]
    
    $ docker build -t test .
    ...
    
    $ docker run test
    test
    
    $ docker run test "hello world"
    hello world
    

    Remember to chmod 755 start.sh before building the container or the script won’t execute.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.