• Empleos
  • Sobre nosotros
  • Empleos
    • Inicio
    • Empleos
    • Cursos y retos
  • Empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

389
Vistas
Docker image having apscheduler does not run at all

I am new to docker, so bear with me on this.

I have a app.py file, which simply uses apscheduler to print a sentence on the console. I have followed the structure from the official guide for the python file. When I run the file on my console, it runs as expected. (prints the Tick statement every 10 seconds.)

Now, I want to dockerize it and upload the image to dockerhub. I followed the docker documentations and this is how my DockerFile looks like:

FROM python:3
COPY requirements.txt .
COPY app.py .
RUN pip install --trusted-host pypi.python.org -r requirements.txt
CMD [ "python", "app.py" ]

I have listed the module names in requirements.txt as below:

datetime
apscheduler

The folder is flat. app.py and requirements.txt are in the same level in the directory.

|
|- app.py
|- requirements.txt

I use below commands to build the docker image:

docker build . -t app1:ver3

The docker image builds successfully and shows up when I do

docker images

Problem is, when I run the docker image with

docker run app1:ver3

the image does not show any output.

In fact the image shows as listed when I do docker ps - which is expected but the run command should show me print statements on the console every 10 seconds.

over 3 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

There are two things here

You need to use docker run -it app1:ver3

-i: Interactive mode
-t: Enable TTY

I believe just -t also may do the job. See the link below for details

https://docs.docker.com/engine/reference/run/

over 3 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda