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- what real value does it bring for our team?
  • why is the status Exited (-1) when docker stop some container
  • Boot2Docke init: boot2docker init error in run: Failed to initialize machine “boot2docker-vm”: exit status 1
  • Why does docker-compose not lookup the IP address from the MySQL container?
  • Dockerfile replicate the host user UID and GID to the image
  • How to create docker containers with the same internal IP address?
  • 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.

  • Reduce SYS_ADMIN Linux capabilities
  • Mongodb Docker - Creating initial users and setting up initial structures
  • Netcating from client to server with docker-ed application lags initially
  • Monitor Docker container with Zabbix
  • Error: unknown shorthand flag: 'r' in -r
  • The command '/bin/sh -c returned a non-zero code: 127
  • 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.