1

I made a Docker container to act as a Jupyter server

docker run -i -t -p 8888:8888 continuumio/anaconda3 /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"

Is it possible to start the stopped container without executing the specified command? At startup it stops when trying to create an existing directory.

kosh@LinuxPC:~$ docker ps -a --no-trunc
CONTAINER ID                                                       IMAGE               COMMAND                                                                                                                                                                                                    CREATED             STATUS                     PORTS               NAMES
bb9ff79baf4b2a18289e14338cecdd3cdfa3bbe2a84cba0a63430de1e624b769   condaim             "/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'"   24 hours ago        Exited (1) 2 minutes ago                       jovial_clarke

kosh@LinuxPC:~$ docker start -i jovial_clarke
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done

# All requested packages already installed.

mkdir: cannot create directory ‘/opt/notebooks’: File exists
Kosh
  • 960
  • 2
  • 13
  • 28
  • I think the answer is pretty much different than the one mentioned above. he does not want different command but way to fix to the existing command. – Adiii Jun 29 '20 at 11:54
  • I had experienced a situation when I had to retrieve a file from an already stopped container. Therefore information about staring a stopped container with a different command was useful. Your advice how to fix the command to avoid this in the future also helped. – Kosh Jun 29 '20 at 12:16

1 Answers1

1

Whenever you stop and then stop the container, it Will always run the entry command. So all you to change the command when you first start the container.

so the logic should be create the directory if not exist that should be mkdir -p /opt/notebooks as the error come from this command.

so update the docker run command accordingly and it will work for next start.

docker run -i -t -p 8888:8888 continuumio/anaconda3 /bin/bash -c "/opt/conda/bin/conda install jupyter -y --quiet && mkdir -p /opt/notebooks && /opt/conda/bin/jupyter notebook --notebook-dir=/opt/notebooks --ip='*' --port=8888 --no-browser"
Adiii
  • 54,482
  • 7
  • 145
  • 148