Docker container closes immediately when using --rpc - docker

When running the command
sudo docker run -d --name ethereum -p 8545:8545 -p 30303:30303 ethereum/client-go --rpc --rpcaddr "0.0.0.0" --rpcapi="db,eth,net,web3,personal" --rpccorsdomain "*" --dev
the container closes almost immediately. Removing all the "rpc" to leave
sudo docker run -d --name ethereum -p 8545:8545 -p 30303:30303 ethereum/client-go
the container runs in the background as expected. Why is this so and how can I keep the container running long enough to exec on it?

After running command in foreground as #Andy Ray suggested, it turns out the issue with the rpc flag was due to it being replaced with the http flag as outlined in this answer.

Related

Run Multiple Docker Images from One Bash script

I have a bash file that runs my apps docker image using docker run -it --network test_network -p 8000:8000 testApp but I also need to run my mysql image using docker run -it --network test_network -p 3308:3308 mysql/mysql-server
Normally I open a separate terminal window manually to run each one but I'm trying to edit my bash script so that it can do both for me. Not sure how though?
You can run both in the detached mode. That will not block the script and allow you to run both together. For that, you need to use the -d or --detach flag.
docker run --detach -it --network test_network -p 8000:8000 testApp
docker run --detach -it --network test_network -p 3308:3308
mysql/mysql-server
Edit:
While the approach mentioned above works, it is better to use docker compose to run multiple containers.

Docker: how to to get access to interactive mode once server started in foreground?

I am running Kurento on debian through Docker with
docker run -d --name kurento -p 8888:8888 kurento/kurento-media-server
That starts the kurento server. Problem is : I need to configure /etc/kurento/modules/kurento/WebRtcEndpoint.conf.ini file that runs in docker and I have no idea on how to access it since it runs in background
When I run docker in interactive mode:
docker run -it --name kurento -p 8888:8888 kurento/kurento-media-server
the server runs in foreground, and I cannot do anything except a CTRL+C ( I tried ctrl+Z to put in in BG process)
Any idea ?
If you have to input an initial configuration file, the best way is by using a volume when starting:
docker run -d --name kurento -p 8888:8888 -v /etc/kurento/modules/kurento/:/path/to/your/env/kurento kurento/kurento-media-server
and inside /path/to/your/env/kurento will be your WebRtcEndpoint.conf.ini file
If you just want to jump inside the machine and tinker around, you can 'exec bash':
docker exec -it kurento /bin/bash
Once your container is started and running, you can create a bash session in that container with below command:
docker exec -ti <container_name> bash

docker web application image needs keep running

I've found similar questions but didn't find the answers helpful, so I'm putting my question here. I have a Dockerfile:
FROM websphere-liberty
COPY server.xml /opt/ibm/wlp/usr/servers/defaultServer/
COPY jfpetc /opt/jfpetc/
ADD wasapp.ear /opt/ibm/wlp/usr/servers/defaultServer/dropins/
ENV LICENSE accept
EXPOSE 80 9080 9448 9443 9060
I then build the image and try to run it with the command:
docker run -d -p 9080:9080 -p 9443:9443 wasapp
Then docker ps doesn't show anything running, and docker ps -a shows it exited. Which command can keep this web application running so I can access the login page?
try this :
docker run -it -d -p 9080:9080 -p 9443:9443 wasapp

Docker : How to run a service and a terminal in one command?

I'm running an apache server like this
docker run -d -p 80:80 php:apache /usr/sbin/apache2ctl -D FOREGROUNDD
Then I determine the name of the container with
docker ps
and execute an interactive shell on the container with
docker exec -ti hungry_fermi bash
It works well, but I would like to do the same in one command. I've tried
docker run -ti -d -p 80:80 php:apache /bin/bash -c 'bash; apache2ctl -D FOREGROUND'
The problem is that, I don't obtain a terminal and the command returns.
You're trying this:
docker run -ti -d -p 80:80 php:apache \
/bin/bash -c 'bash; apache2ctl -D FOREGROUND'
There are several problems here. First, you're using the -d command line option, which asks the docker client to detach and leave the container running. You will never get an interactive shell when using -d.
Secondly, your command -- bash; apache2ctl -D FOREGROUND -- would run bash, wait for bash to exit, then run httpd. You can instead do something like this:
docker run -ti -p 80:80 php:apache \
/bin/bash -c 'apachectl start; bash'
This would start Apache in the background (because there is no -D FOREGROUND), and then start bash...but I'm not really clear why you would want to do this, because now if you were to exit your shell the container would exit as well (taking Apache with it).
I think you are much better simply starting Apache the way you are now, and using docker exec to get a shell inside the container.

how to configure docker container to run /usr/sbin/sshd upon startup

I have a docker container, which I need to run as a deamon with -d flag.
Is there a way to specify, that I want to run /usr/sbin/sshd as a startup process for this container?
I have tried this, but my container did not stay around:
sudo docker run -p 9000:9000 -d me/my-container /usr/sbin/sshd
So within a docker container, you'll want sshd to actually run in the foreground (not as a daemon), because docker itself will treat the container as a daemon. You'll also need to make sure sshd uses the right port. So try:
sudo docker run -p 9000:9000 -d me/mycontainer /usr/sbin/sshd -p 9000 -D

Resources