I took a docker course at udemy, so I will summarize a part of it as a memorandum. This time I would like to write the code to start jupyter-lab based on ubuntu in the docker file and actually create the container.
dockerfile
# FROM =>Select a base image
FROM ubuntu:latest
# RUN =>Call a command
# apt-Upgrade get and install the required packages
RUN apt-get update
RUN apt-get install -y \
wget \
vim
# WORKDIR =>Create and move an arbitrary directory directly under the root on the container side
WORKDIR /opt
#Install anaconda3 and delete the original executable file
# wget =>Specify the URL to download the file
# sh =>Run a shell script
# -b =>Avoid interactive operations
# -p =>Specify the installation destination
# rm =>Delete the specified file
# -f =>Forcibly execute
RUN wget https://repo.continuum.io/archive/Anaconda3-2019.10-Linux-x86_64.sh && \
sh /opt/Anaconda3-2019.10-Linux-x86_64.sh -b -p /opt/anaconda3 && \
rm -f Anaconda3-2019.10-Linux-x86_64.sh
#PATH of anaconda3
# ENV =>Change environment variables
ENV PATH /opt/anaconda3/bin:$PATH
#pip upgrade
RUN pip install --upgrade pip
#Return directly under root
WORKDIR /
#Open jupyter lab when container starts
# CMD =>Specify the command to be executed when the container starts
# "jupyter", "lab" =>Launch jupyter lab
# "--ip=0.0.0.0" =>Remove ip restrictions
# "--allow-root" =>Allow root user, not good for security
# "LabApp.token=''" = >It can be started without a token. Not good for security
CMD ["jupyter", "lab", "--ip=0.0.0.0", "--allow-root", "--LabApp.token=''"]
Run in the directory where the Dockerfile is located
docker build -t my-anaconda .
-t
Give the image you want to build any name you like.
.
The directory where the dockerfile is located is specified.
This time, specify the current directory.
docker run -it \
-p 8888:8888 \
--rm \
--name my-container(Any)\
-v Desktop/ds_python:/opt \
my-anaconda
When you run this container
I 11:42:41.250 LabApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
[W 11:42:41.535 LabApp] All authentication is disabled. Anyone who can connect to this server will be able to run code.
[I 11:42:41.546 LabApp] JupyterLab extension loaded from /opt/anaconda3/lib/python3.7/site-packages/jupyterlab
[I 11:42:41.546 LabApp] JupyterLab application directory is /opt/anaconda3/share/jupyter/lab
[I 11:42:41.548 LabApp] Serving notebooks from local directory: /
[I 11:42:41.548 LabApp] The Jupyter Notebook is running at:
[I 11:42:41.548 LabApp] http://23a5a126fd40:8888/
[I 11:42:41.548 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 11:42:41.552 LabApp] No web browser found: could not locate runnable browser.
After that, enter localhost: 8888
in the web browser and check it.
OK when this comes out on the screen
After that, if you want anaconda to have any library or package, you can install it by writing RUN
in the docker file.
Next, I would like to write a docker file for web development.
https://qiita.com/komiya_____/items/96c14485eb035701e218 https://www.udemy.com/course/aidocker/learn/lecture/20311429#overview
Recommended Posts