Container を起動する
sudo docker run --rm -d -it -p 8000:8888 image_name:vX.X bash
--rm
: This option tells Docker to remove the container once it stops.
-d
: Runs the container in detached mode (keep running even after the command window stops)
-it
: This allows you to run the container interactively with a terminal.
-p 8000:8888
: This maps port 8000 on your host machine (arbitrary) to port 8888 on the Docker container (default unless otherwise specified in the container).
docker_image:vX.X
: Docker image to use
bash
: This starts a bash shell in the container, allowing you to run commands interactively.
Container 内のJupyter lab を使用する
Container 内でJupyter lab を起動する
jupyter lab --allow-root --ip=0.0.0.0 --port=8888 --no-browser
jupyter lab list
でjupyer lab が走っているか確認できる。いらないものは px aux | grep jupyter
で見つけて kill <PID>
する。
Container とJupyter lab を同時に立ち上げる
docker run -d --restart always -p 0:8888 docker_image:vX.X jupyter lab --allow-root --ip=0.0.0.0 --port=8888 --no-browser
--restart
: You can specify the restart policy using the --restart flag when you run your container. Here are a few options for the restart policy:
• no
: Do not automatically restart the container (default).
• always
: Always restart the container if it stops.
• unless-stopped
: Restart the container unless it has been manually stopped.
Container ⇔ Host 間のデータのやり取り
Container 内からHost にデータをコピーする
docker cp <container_id_or_name>:<source_path> <destination_path_on_host>
Host からContainer 内にデータをコピーする
docker cp <destination_path_on_host> <container_id_or_name>:<destination_path>