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

289
Visualizações
Adding config file in docker run command

This docker command works as expected:

docker run -i -t -p 7778:8888 continuumio/miniconda3 /bin/bash -c "/opt/conda/bin/conda install jupyter -y --quiet && mkdir /opt/notebooks && /opt/conda/bin/jupyter notebook --notebook-dir=/opt/notebooks --ip='*' --port=8888 --no-browser --allow-root"

It starts miniconda with python 3 version installed. The problem is that it generates a random password to access jupyter when I go to ...

http://somesite.com:7778

And there is no way to change the password. The only way is to create or update the config file jupyter_notebook_config.py found in home directory (sub-folder: ~/.jupyter) How do I save this file on host and mount it using -v parameter?

I can do this manually if I follow these 3 steps:

1) Login to ipython docker container

docker exec -it 6cbc bash

2) Run the following command...

jupyter notebook --generate-config

3) Copy the config file to the container using a command something like this...

docker cp ipython_kernel_config.py  6cbc8d829e4a:/.jupyter/jupyter_notebook_config.py

I am looking for a way to merge these 3 steps into the docker run command.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Have you tried adding a volume mount to the run command?

Something like this.

docker run -i -t -v /tmp/.jupyter:/.jupyter/ -p 7778:8888 continuumio/miniconda3 /bin/bash -c "/opt/conda/bin/conda install jupyter -y --quiet && mkdir /opt/notebooks && /opt/conda/bin/jupyter notebook --notebook-dir=/opt/notebooks --ip='*' --port=8888 --no-browser --allow-root"

This assumes you have a /tmp/.jupyter directory, and feel free to change to something else.

Also, this is a messy command, any reason why you don't create your own image using a Dockerfile? Here is a rough example, haven't tested so probably some typos and syntax errors, you but get the idea.

FROM continuumio/miniconda3
RUN /opt/conda/bin/conda install jupyter -y --quiet
RUN mkdir /opt/notebooks
# COPY in your custom config 
COPY ipython_kernel_config.py /.jupyter/jupyter_notebook_config.py
EXPOSE 8888
# RUN the notebook
CMD ["/opt/conda/bin/jupyter", "notebook", "--notebook-dir=/opt/notebooks", "--ip='*'", "--port=8888", "--no-browser", "--allow-root"]

To build and run you would do something like this.

docker build -t myminiconda3 .
docker run -it -p 7778:8888 myminiconda3

you can even mount in your local files if you want.

docker run -it -v `pwd`:/mycode -p 7778:8888 myminiconda3

And even run as a daemon

docker run -d -v `pwd`:/mycode -p 7778:8888 myminiconda3
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