How do I run background applications using Docker?

1

I'm trying to run my application in Python inside a container, but I need to install a proxy dependency that I use: Luminati, the problem is that apparently the luminati is not running in the background after I initialize the container.

I tried to run as follows:

docker run -it test_app:latest

When running a ps ax the application of the luminati is not running!

docker-compose.yml

version: '3'

services:
  app:
    build: .
    volumes:
      - .:/shared
    networks:
      - vnet-front

networks:
   vnet-front:
     driver: bridge

Dockerfile

FROM python:3.6-alpine AS build-ev

RUN apk add nodejs
RUN apk add npm
RUN npm install -g @luminati-io/luminati-proxy --unsafe-perm
RUN mkdir /app
WORKDIR /app
COPY . /app
RUN luminati --config luminati.json
ENTRYPOINT ["python", "test.py"]
    
asked by anonymous 30.07.2018 / 18:48

1 answer

1

In order to start your application at the time the container is called, instead of using RUN you use CMD :

Dockerfile changed:

FROM python:3.6-alpine AS build-ev

RUN apk add nodejs
RUN apk add npm
RUN npm install -g @luminati-io/luminati-proxy --unsafe-perm
RUN mkdir /app
WORKDIR /app
COPY . /app

CMD luminati --config luminati.json && python test.py

So, at the moment startar your image (something like):

docker run -d -p 22999:80 test_app:latest

The application ( luminati ) will be running and its test.py as well.

    
30.07.2018 / 20:13