I have a node app running on localhost:3000 and want to deploy it publicly. Doing this by running inside a VM and using port forwarding was easy, but I'm struggling with docker and deployment of a container.
I just pushed a new container image to my private docker repo with docker-compose push
and have continuous deployment enabled in my Azure web app. The logs show it running the image with docker run
subcommand within the web app automatically as expected.
It takes a really long time for my app within the container to run, and by the time it runs, it times out and Azure seems to terminate it.
My env vars needed for app to run were manually entered in Application Settings within the Azure portal for the web app.
2018_09_18_RD00155D258812_default_docker.log:
2018-09-18T00:14:27.228360304Z level: 'info',
2018-09-18T00:14:27.228366005Z label: 'app/server.js',
2018-09-18T00:14:27.228370005Z timestamp: '2018-09-18T00:14:27.226Z',
2018-09-18T00:14:27.228374605Z [Symbol(level)]: 'info' }
2018-09-18T00:14:27.844023142Z { message: 'createdQueue; results = {"name":"webhook-queue-dev","approximateMessageCount":1,"created":false}',
2018-09-18T00:14:27.844050643Z level: 'debug',
2018-09-18T00:14:27.844055943Z label: 'data-controllers/azure-queue.js',
2018-09-18T00:14:27.844060543Z timestamp: '2018-09-18T00:14:27.843Z',
2018-09-18T00:14:27.844065044Z [Symbol(level)]: 'debug' }
2018_09_18_RD00155D258812_docker.log:
2018-09-18 00:14:10.809 INFO - Starting container for site
2018-09-18 00:14:10.809 INFO - docker run -d -p 18365:80 --name webhook-web-app_0 -e WEBSITE_SITE_NAME=webhook-web-app -e WEBSITE_AUTH_ENABLED=False -e PORT=80 -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_INSTANCE_ID=123 -e HTTP_LOGGING_ENABLED=1 jtara1/webhook
2018-09-18 00:18:04.705 ERROR - Container webhook-web-app_0 for site webhook-web-app did not start within expected time limit. Elapsed time = 230.8677441 sec
docker-compose.yml
version: '3'
services:
webhook:
image: jtara1/webhook
build:
context: .
dockerfile: Dockerfile
command: node server.js
volumes:
- .:/app
- /app/node_modules/
expose:
- "3000"
- "80"
ports:
- "3000:80"
Dockerfile
FROM node:8-alpine
WORKDIR /app
COPY package.json .
RUN npm install
COPY . .
# Expose our server port.
EXPOSE 3000 80
# Run our app.
CMD ["node", "server.js"]
I test the same container image on localhost with
$ docker-compose up -d
$ docker-compose exec webhook sh
> wget localhost:3000
$ docker-compose logs
$ docker-compose down
$ docker
instead of$ docker-compose
.docker build -t webhook2 .
docker push jtara1/webhook
docker build --no-cache -t webhook .
) How does docker find the ip on which to host my app? It's been on localhost. Running apps in VMs, I've usedhostname -I
as my hostname for public deployment.