総数:5 今日:1 昨日:4
Memorandums
on windows

install Php Env on Windows11 by Docker
DockerでPHP+MySQL開発環境を作る

もくじ

参考url
DockerでPHP+MySQL開発環境を作る

異なるバージョンである Anaconda3-2023.03-1 をもとに、別のコンテナを作成する。

Dockerfileの準備

C:\Users\ryu\Documents\docker-python_Anaconda3-2023.03-1 に以下の内容のファイルを作成する

Dockerfile

FROM ubuntu:22.04

RUN apt-get update && apt-get install -y sudo wget vim curl gawk make gcc
RUN sudo apt-get install bzip2

RUN wget https://repo.anaconda.com/archive/Anaconda3-2023.03-1-Linux-x86_64.sh && \
    sh Anaconda3-2023.03-1-Linux-x86_64.sh -b  && \
    rm -f Anaconda3-2023.03-1-Linux-x86_64.sh && \
    sudo curl -sL https://deb.nodesource.com/setup_20.x | sudo bash -  && \
    sudo apt-get install -y nodejs

ENV PATH $PATH:/root/anaconda3/bin

RUN pip install --upgrade pip
RUN pip install pandas_datareader
RUN pip install mplfinance
RUN pip install japanize-matplotlib

RUN wget --quiet https://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz -O ta-lib-0.4.0-src.tar.gz && \
    tar xvf ta-lib-0.4.0-src.tar.gz && \
    cd ta-lib/ && \
    ./configure --prefix=/usr && \
    make && \
    sudo make install && \
    cd .. && \
    pip install TA-Lib && \
    rm -R ta-lib ta-lib-0.4.0-src.tar.gz

RUN mkdir /workspace

CMD ["jupyter-lab", "--ip=0.0.0.0","--port=8888" ,"--no-browser", "--allow-root", "--LabApp.token=''"]

docker-compose.yml

version: "3.7"
services:
  jupyterlab:
    build: .
    container_name: docker-python_anaconda3-2023.03-1
    volumes:
      - '.:/workspace'
    environment:
      - JUPYTER_ENABLE_LAB=yes
    ports:
      - "8888:8888"
    platform: linux/amd64

Dockerfileからイメージを作成、コンテナの作成、実行

Windows powerShellを管理者として起動する

PS C:\Users\ryu> 

wslコマンドにて、ubuntuを起動する

PS C:\Users\ryu> wsl 
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

Welcome to Ubuntu 22.04.2 LTS (GNU/Linux 6.6.114.1-microsoft-standard-WSL2 x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

 * Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s
   just raised the bar for easy, resilient and secure K8s cluster deployment.

   https://ubuntu.com/engage/secure-kubernetes-at-the-edge

This message is shown once a day. To disable it please create the
/home/ryu/.hushlogin file.
ryu@LAPTOP-KRM3VC55:/mnt/c/Users/ryu$

wslが起動しない場合、ファイル破損 の可能性があるのでpowershellにて下記のコマンドを実行し、 ファイル修復 する

PS C:\Users\ryu> sfc /scannow
PS C:\Users\ryu> dism /online /cleanup-image /restorehealth

Dockerfileからイメージを作成、コンテナの作成、実行

$ cd Documents/docker-python_Anaconda3-2023.03-1/
$ docker-compose up --build -d

実行結果

確認

$ docker container ls
CONTAINER ID   IMAGE                      COMMAND                  CREATED          STATUS          PORTS                                         NAMES
984e1b1a06e8   docker-python-jupyterlab   "jupyter-lab --ip=0.…"   29 minutes ago   Up 29 minutes   0.0.0.0:8888->8888/tcp, [::]:8888->8888/tcp   docker-python
$

起動中の docker コンテナのシェルに入る

$ docker exec -i -t 984e1b1a06e8 /bin/bash
root@984e1b1a06e8:/#

pythonのバージョン確認

# python -V
Python 3.13.9
# 

pipのバージョン確認

# pip -V
pip 26.1.1 from /root/anaconda3/lib/python3.13/site-packages/pip (python 3.13)
#

pipでインストール済みのライブラリのリスト

# pip list

anacondaでインストール済みパッケージの確認

# conda list

jupiter labの起動

ブラウザで http://localhost:8888/lab に接続する

on windows


トップ   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS