[https://github.com/gtriggiano/ngrok-tunnel ] runs ngrok inside a container. Ngrok is required to run in the container to avert security risks. But am facing problems after running the scripts, which generates the url
$ docker pull gtriggiano/ngrok-tunnel
$ docker run -it -e "TARGET_HOST=localhost" -e "TARGET_PORT=3000" -p 4040 gtriggiano/ngrok-tunnel
am running my rails app on localhost:3000
is it my problem or can it be fixed by altering the scripts(inside the repo)?
I couldn't get this working but switched to https://github.com/shkoliar/docker-ngrok and it works brilliantly.
In my case I added it to my docker-compose.yml file:
ngrok:
image: shkoliar/ngrok:latest
ports:
- 4551:4551
links:
- web
environment:
- PARAMS=http -region=eu -authtoken=${NGROK_AUTH_TOKEN} localdev.docker:80
networks:
dev_net:
ipv4_address: 10.5.0.10
And it's started with everything else when I do docker-compose up -d
Then there's a web UI at http://localhost:4551/ for you to see the status, requests, the ngrok URLs, etc.
The Github page does have examples of running it manually from the command line too though, rather than via docker-compose:
Command-line Example The example below assumes that you have running
web server docker container named dev_web_1 with exposed port 80.
docker run --rm -it --link dev_web_1 shkoliar/ngrok ngrok http dev_web_1:80
With command line usage, ngrok session is active until it
won't be terminated by Ctrl+C combination.
No. if you execute -p with single number it's container port - host port is randomly assigned.
Using -p, --publish ip:[hostPort]:containerPort at docker run can specify the the host port with the container port.
as of now the 4040 of container is exposed. Not sure if your service listens by default on it.
To get localhost port execute
docker ps
you'll see the actual port it's not listening on.
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1aaaeffe789d gtriggiano/ngrok-tunnel "npm start" About a minute ago Up About a minute 0.0.0.0:32768->4040/tcp wizardly_poincare
here it's listening on localhost:32768
this composer works for me. Note that in the entrypoint command for ngrok you have to reference the other service by name
version: '3'
services:
yourwebserver:
build:
context: ./
dockerfile: ...
target: ...
container_name: yourwebserver
volumes:
- ...
ports:
- ...
extra_hosts:
- 'host.docker.internal:host-gateway'
depends_on:
- ngrok
ngrok:
image: ngrok/ngrok:alpine
environment:
NGROK_AUTHTOKEN: '...'
command: 'http yourwebserver:80'
ports:
- '4040:4040'
expose:
- '4040'
I'm not sure if you have already solved this but when I was getting this error I could only solve it like this:
# docker-compose.yml
networks:
- development
I also needed to expose the 3000 port of my web container because it still wasn't exposed.
# docker.compose.yml
web:
expose:
- "3000"
My container for the server running on development is also under the development network. The only parameters, I believe, you should pass for the container to execute are image, ports, environment with DOMAIN and PORT for the server container, a link, and an expose on your web container:
# docker-compose.yml
ngrok:
image: shkoliar/ngrok
ports:
- 4551:4551
links:
- web
networks:
- development
environment:
- DOMAIN=squad_web
- PORT=3000
Actually to make ngrok work with your docker container you can install it outside of your project just like the manual on their website says. And then add
nginx:
labels:
- "traefik.http.routers.${PROJECT_NAME}_nginx.rule=Host(`${PROJECT_BASE_URL}`, `aaa-abc-xxx-140-177.eu.ngrok.io`)"
This particular example is for docker4drupal docker-compose file and traefik mapped as 80:80
Related
I'm trying to build a Jenkins docker container by following this page so I can test locally. Problem is with this is that once I've ran docker run -it -p 8080:8080 jenkins/jenkins:lts it seems I cannot use the same port for my docker-compose.yml:
version: '3.8'
services:
jenkins:
image: jenkins/jenkins:lts
container_name: jenkins
user: root
privileged: true
ports:
- 8080:8080
- 50000:50000
volumes:
- .jenkins/jenkins_configuration:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
The error shown in PowerShell (I'm on windows 10 if that's relevant) is:
Error response from daemon: driver failed programming external connectivity on endpoint jenkins (xxxx): Bind for 0.0.0.0:8080 failed: port is already allocated
I've made sure it's not affected from another container, image or volume and have deleted everything apart from this.
I wish to use Jenkins locally but how can I get around this? I'm not familiar with networking and what I've googled so far has not seemed to work for me. I would like this to be able to use Jenkins ui on localhost:8080
If port 8080 is already allocated on your host machine, you can just map a different one to 8080 of the container instead. Two things can't be mapped to the same port on the host machine. In order to map 8081 for example, change your compose to the following:
version: '3.8'
services:
jenkins:
image: jenkins/jenkins:lts
container_name: jenkins
user: root
privileged: true
ports:
- 8081:8080 # a different port is mapped here
- 50000:50000
volumes:
- .jenkins/jenkins_configuration:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
Then, you just need to access the container started by docker-compose with port localhost:8081 rather than localhost:8080.
I'm using php-fpm which runs for default on the port 9000. The problem's that I have other docker container based on php-fpm, so I need to change the default port to another one, in order to not confuse nginx.
This is my Dockerfile:
FROM php:8.0.2-fpm-alpine
RUN sed -i 's/9000/9001/' /usr/local/etc/php-fpm.d/zz-docker.conf
WORKDIR /var/www/html
CMD ["php-fpm"]
EXPOSE 9001
I tried to use the sed command to replace the port 9000 with 9001.
Inside my docker-compose file I have this configuration:
version: '3.9'
services:
php-fpm:
container_name: app
restart: always
build:
context: .
dockerfile: ./docker/php-fpm/Dockerfile
ports:
- "9001:9000"
volumes:
- ./src:/var/www/html
- ./docker/php-fpm/config/www.conf:/usr/local/etc/php-fpm.d/www.conf
- ./src/public:/app/public
- ./src/writable:/app/writable
nginx:
image: nginx:stable-alpine
container_name: nginx
restart: always
volumes:
- ./src:/var/www/html
- ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf
- ./docker/nginx/sites/:/etc/nginx/sites-available
- ./docker/nginx/conf.d/:/etc/nginx/conf.d
depends_on:
- php-fpm
environment:
VIRTUAL_HOST: ${HOST}
LETSENCRYPT_HOST: ${HOST}
LETSENCRYPT_EMAIL: ${EMAIL}
as you can see I have exposed the port 9001 also in the docker-compose file.
The file default.conf available within conf.d folder contains this:
upstream php-upstream {
server php-fpm:9001;
}
the problem's that for some reason, when I load my site I get the error 500. So this means that the stream doesn't send any signal. If I change to port 9000 everything works, but the stream is wrong 'cause it's the content of another application.
How can I correctly change the default port?
I think the problem is not the sed command itself, it's related to the wrong file you mentioned for it.
/usr/local/etc/php-fpm.d/zz-docker.conf
this is the file you are trying to change the port in it but inside your docker-compose file you are mapping something else
./docker/php-fpm/config/www.conf:/usr/local/etc/php-fpm.d/www.conf
Keep in mind that your nginx docker connects via the internal docker net work, your docker host port mapping 9001:9000 is not taken into account.
If your php-fpm is really listening on port 9001, then that is the port you must use in your nginx config.
Also EXPOSE is primarily declarative and does not expose anything by itself (https://docs.docker.com/engine/reference/builder/#expose) the corresponding service must still be configured correctly to use that port.
for this line in Dockerfile is not working(?):
RUN sed -i 's/9000/9001/' /usr/local/etc/php-fpm.d/zz-docker.conf
so I decided to make this change after the container is up with:
docker exec -i your_container bash -c 'sed -i 's/9000/9001/' /usr/local/etc/php-fpm.d/zz-docker.conf'
and then restert the container to make changes happened
hope help you
i am using akka http server in my app and mongodb as a backed database, akka http uses standard input to keep running the server,
here is how i am binding it
val host = "0.0.0.0"
val port = 8080
val bindingFuture = Http().bindAndHandle(MainRouter.routes, host, port)
log.info("Server online ")
StdIn.readLine()
bindingFuture
.flatMap(_.unbind()) // trigger unbinding from the port
.onComplete(_ => system.terminate()) // and shutdown when done
i need to dockerize my app docker closes the standard input by default when it starts the container, to keep it running we need to provide -i option with the container like this
docker run -p 8080:8080 -i imagename:tag
now the problem is i need to use docker-compose to start my app with mongo
here is my docker-compose.yml
version: '3.3'
services:
mongodb:
image: mongo:4.2.1
container_name: docker-mongo
ports:
- "27017:27017"
akkahttpservice:
image: app:0.0.1
container_name: docker-app
ports:
- "8080:8080"
depends_on:
- mongodb
how can i provide the -i option with docker-app container
Note after doing docker-compose up
docker exec -it containerid sh
did not worked for me
Any help would be appreciated
I have the following docker-compose.yml to start a webserver with PHP.
version: "2.0"
services:
nginx:
image: nginx
ports:
- "8000:80"
volumes:
- ./web:/web
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
php:
image: php:${PHP_VERSION}-fpm
volumes:
- ./web:/web
After running docker-compose up, I can access my website perfectly at http://localhost:8000. But if I then access the nginx container, with:
$ docker-compose run nginx bash
and within the container I run:
$ service nginx stop
I still can see the website http://localhost:8000 being displayed in the browser.
How can it be that after stopping the server in the container, the website is still being delivered?
The docker-compose run command starts a new container, you're stopping nginx in that new container, what you want is docker attach nginx
The documentation is located here.
I am trying to run the beego application using docker with the help of docker-compose. I am able access the demo application in http://localhost:8081 URL after running docker-compose up.
docker-compose.yml
version: "2"
services:
app:
build: .
volumes:
- .:/go/src/hello
ports:
- "8080:8080"
working_dir: /go/src/hello
command: bee run
Dockerfile
FROM golang:1.10
## Install beego and the bee dev tool
RUN go get github.com/astaxie/beego && go get github.com/beego/bee
app.conf from beego framework
appname = hello
httpport = 8081
runmode = dev
How can I overwrite the httpport(8081) in app.conf using ports(8080) number used in app from docker-compose.yml. After running docker-compose up application runs in port 8081 not in 8080. How can I solve this?
You shouldn't need to update the app.conf to 8080 use the ports to have the docker container listen on 8081 and respond to 8080.
Change - "8080:8080" to - "8080:8081"
First port is what the docker container will respond to and the second port is the port of the application within the container.