Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

307
Visualizações
Docker input/output outside the container

I created a docker container with a python script. The python script takes an input file, does some processing and saves output file at some specified location.

docker run /app/script.py --input /data/input.csv --output /data/output.csv

Since the input file can be different every time I run the script, I want it to be outside the docker container. I also would like to store the output somewhere outside the container.

docker run /app/script.py --input /my/local/location/outside/docker/input.csv --output /my/local/location/outside/docker/output.csv

Does docker support this? If so, how would one be able to achieve it?

My Dockerfile looks like the following:

FROM phusion/baseimage

RUN apt-get update
RUN apt-get install -y build-essential
RUN apt-get install -y python-dev
RUN apt-get install -y python-pip
RUN apt-get install -y python-numpy && \
    apt-get install -y python-scipy

COPY ./requirements.txt /app/requirements.txt
COPY ./src/script.py /app/script.py

WORKDIR /app
COPY . /app
over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

You could mount a directory with the file inside as a Docker data volume using the -v option: https://docs.docker.com/engine/tutorials/dockervolumes/

docker run -d -P --name myapp -v /app mydir/app python script.py

This will have the added benefit of allowing you to stop the container, make changes to the file, and start the container and see the change reflected within the container.

over 4 years ago · Santiago Trujillo Relatório

0

so you should add to your Dockerfile a line

ENTRYPOINT ["python","/app/script.py"]

and a

CMD myinput

or something similar,

read

What is the difference between CMD and ENTRYPOINT in a Dockerfile?

read the docs about

https://docs.docker.com/engine/reference/builder/#entrypoint

and

https://docs.docker.com/engine/reference/builder/#cmd

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda