I am trying to deploy a Docker image on Heroku and am trying to understand how to expose multiple ports. Here is the Docker command that I am trying to run in the Heroku deploy:
docker run \
-p 2222:22 \
-p 33306:3306 \
-p 27017:27017 \
-p 28015:28015 \
-p 29015:29015 \
-p 8080:8080 \
test/db-migration
How do I do this in Heroku?
You can't - you should use the $PORT environment variable which will be randomly assigned and then mapped to port 80 by the Heroku routers. Also, only http requests are accepted. See https://devcenter.heroku.com/articles/container-registry-and-runtime#dockerfile-commands-and-runtime for more details.
You may want to look at Dockhero add-on. It's a good way to deploy supplementary resources alongside your Heroku app, and it supports docker-compose with multi-port mapping. The web app itself should still be running on Heroku dynos.
Related
The software I'm trying to deploy is https://github.com/gitbitex/gitbitex-new
To sum up, it works. But only on linux machines.
Here is the script I used (from github).
# start zookeeper
docker run -d --name zookeeper-server \
--network host \
-e ALLOW_ANONYMOUS_LOGIN=yes \
bitnami/zookeeper:latest
# start kafka
docker run -d --name kafka-server \
--network host \
-e ALLOW_PLAINTEXT_LISTENER=yes \
-e KAFKA_CFG_ZOOKEEPER_CONNECT=127.0.0.1:2181 \
bitnami/kafka:latest
# start redis
docker run -d --name redis-server \
--network=host \
redis
# start mysql
docker run -d --name mysql \
--network=host \
-e MYSQL_ROOT_PASSWORD=123456 \
mysql:5.7
# Please wait for MySQL to start before executing the following command
docker exec -it mysql mysql -uroot -p123456 -e "create database gitbitex;"
# start gitbitex
# open the browser and visit http://127.0.0.1/trade/BTC-USDT
docker run -d --name gitbitex \
--network=host \
greensheng/gitbitex
Firstly, I've tried to deploy it on vds using guide on github. And it worked without any problem.
Then I've tried to deploy it on my local machine which uses wsl with docker(integration is enabled) and it didn't work. Just can't load the webpage in browser. Curl from wsl also doesn't work, it says: connection refused.
Tried to deploy on a different linux machine, it worked again.
Tried different configuration using docker compose(cause this is what I'll need to do next). I've almost figured out how to setup it without network_mode: host but spring app itself throws exceptions anyway. With network_mode: host it doesn't work even on remote machine(but maybe it's my bad), but all containers are running properly, without errors.
It works on linux machine, but doesn't on Windows. As David Maze told in comments, it's because --network=host doesn't work on docker desktop.
I'll try instead to setup networking put everything into compose and make it work.
UPD: spent a lot of time trying to setup it without --network=host using docker compose and.. it still doesn't work on Windows. Docker destop is weird..
I have a laravel app but I can't make it run with docker run command. The last two instructions are
EXPOSE 9000
CMD ["php", "artisan", "serve","--port=9000"]
I am trying to make it run trying with:
docker run -p 9000:9000 my_image:latest
docker run --net="host" -p 9000:9000 my_image:latest
docker run --net="bridge" -p 9000:9000 my_image:latest
The only thing I see is the classic laravel output
Laravel development server started: <http://127.0.0.1:9000>
What am I missing?
The problem is 127.0.0.1:9000, i.e., the server is bound to localhost within the container, instead of listening on an external interface. The solution is to use the --host 0.0.0.0 argument, which will bind the server to all available interfaces.
CMD ["php", "artisan", "serve", "--host", "0.0.0.0", "--port=9000"]
I am unable to deploy an existing docker image to Heroku.
Image
docker run -it --name xp-home enonic/xp-home
docker run -d -p 8080:8080 --volumes-from xp-home --name xp-app enonic/xp-app
The steps I took to do it.
heroku login
sudo heroku container:login
sudo docker tag dpd-image registry.heroku.com/hidden-mountain-63983/web
sudo docker push registry.heroku.com/hidden-mountain-63983/web
heroku open -a hidden-mountain-63983
What Am I doing wrong here?
Thank you in advance
I'll answer this for others that might have the same question.
As per the Heroku Container Registry & Runtime (Docker Deploys) documentation, you need to release the image. In your case
heroku container:release registry.heroku.com/hidden-mountain-63983/web
I have Node services which are running in Docker container
I am using shell script to run these services
I want to run three different instances of the same service on 3 different port. say 9011 9022 9033
I also want it to configure it in such a way that after every new deployment it should stop the previous service and remove it
I am using docker rm test-service to remove it but it will remove other instances too.
by this approach only once instance can be running.
Is there any way to remove Docker service running on the specific port.
here is my shell script
#!/bin/bash
ORGANISATION="$1"
SERVICE_NAME="$2"
VERSION="$3"
ENVIRONMENT="$4"
INTERNAL_PORT_NUMBER="$5"
EXTERNAL_PORT_NUMBER="$6"
NETWORK="$7"
docker build -t ${ORGANISATION}/${SERVICE_NAME}:${VERSION} --build-arg PORT=${INTERNAL_PORT_NUMBER} --build-arg ENVIRONMENT=${ENVIRONMENT} --no-cache .
docker stop ${SERVICE_NAME}
docker rm ${SERVICE_NAME}
sudo npm install
sudo npm install -g express
docker run -p ${EXTERNAL_PORT_NUMBER}:${INTERNAL_PORT_NUMBER} --network ${NETWORK} --name ${SERVICE_NAME} --restart always -itd ${ORGANISATION}/${SERVICE_NAME}:${VERSION}
I can not run more than one container with the same name. Can I run the docker service with the same name on 3 different port. if yes what modifications do i need to make in above shell file?
That would be three docker run, each using the same internal port, but mapped to a different host port, with three different names
docker run -p ${EXTERNAL_PORT_NUMBER1}:${INTERNAL_PORT_NUMBER} --name ${SERVICE_NAME1}
docker run -p ${EXTERNAL_PORT_NUMBER2}:${INTERNAL_PORT_NUMBER} --name ${SERVICE_NAME2}
docker run -p ${EXTERNAL_PORT_NUMBER3}:${INTERNAL_PORT_NUMBER} --name ${SERVICE_NAME3}
I want to perform LoadBalance for service
See docker swarm mode
The swarm manager uses ingress load balancing to expose the services you want to make available externally to the swarm.
The swarm manager can automatically assign the service a PublishedPort or you can configure a PublishedPort for the service. You can specify any unused port. If you do not specify a port, the swarm manager assigns the service a port in the 30000-32767 range.
Example:
the following command publishes port 80 in the nginx container to port 8080 for any node in the swarm
$ docker service create \
--name my-web \
--publish 8080:80 \
--replicas 2 \
nginx
I have trouble with docker.
Im trying to create a new instance of rethinkdb on docker. I used the origin command from dockerfile github.
$ docker run -d -p 8080:8080 -p 28015:28015 -p 29015:29015 dockerfile/rethinkdb
But it returned error about image not found from the repository.
Any advice for this issue?
Thank everyone
OS version: Windows 10
Screenshot
That github repo doesn't appear to have been updated in a few years, and all the docker hub links are old. Consider using the official repo on docker hub:
docker run -d -p 8080:8080 -p 28015:28015 -p 29015:29015 rethinkdb