Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker entrypoint with multiple arguments

I am creating Dockerfile to run ethereum node on ubuntu container.

I want to run the below shell commands one after another sequentially in the container.

geth --datadir /home/ubuntu/eth-dev init /home/ubuntu/eth-dev/genesis.json 
geth --networkid 45634 --verbosity 4  --ipcdisable --rpc --port 30301 --rpcport 8545 --rpcaddr 0.0.0.0 console 2>> /home/ubuntu/eth-dev/eth.log

I have create below Entrypoint in the Dockerfile which I believe incorrect.

 ENTRYPOINT ["geth", "--datadir /home/ubuntu/eth-dev", "init /home/ubuntu/eth-dev/genesis.json", "--networkid 45634", "--verbosity 4", "--ipcdisable", "--rpc", "--port 30301", "--rpcport 8545", "--rpcaddr 0.0.0.0", "console 2>> /home/ubuntu/eth-dev/eth.log"] 

can anyone correct the ENTRYPOINT for the above shell command.

like image 948
Rajkumar Natarajan Avatar asked Mar 06 '26 04:03

Rajkumar Natarajan


1 Answers

Put the two commands in a shell script, COPY the shell script in the Dockerfile, then use that shell script as the entrypoint.

docker-entrypoint.sh:

geth --datadir /home/ubuntu/eth-dev init /home/ubuntu/eth-dev/genesis.json 
geth --networkid 45634 --verbosity 4  --ipcdisable --rpc --port 30301 --rpcport 8545 --rpcaddr 0.0.0.0 console 2>> /home/ubuntu/eth-dev/eth.log

Dockerfile:

COPY docker-entrypoint.sh /usr/bin/docker-entrypoint.sh
ENTRYPOINT ["/usr/bin/docker-entrypoint.sh"]

Be sure to chmod +x the script, either before copying or in a RUN command in the Dockerfile.

like image 89
wmorrell Avatar answered Mar 08 '26 19:03

wmorrell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!