Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker 使用尝试 #3

Open
eustomaqua opened this issue Mar 16, 2024 · 4 comments
Open

Docker 使用尝试 #3

eustomaqua opened this issue Mar 16, 2024 · 4 comments

Comments

@eustomaqua
Copy link
Owner

eustomaqua commented Mar 16, 2024

Docker images 安装
本地机 (Win 11)

$ docker pull continuumio/anaconda3
$ docker pull continuumio/miniconda3
$ docker pull ubuntu
$ docker cp Downloads/Anaconda3-2023.03-Linux-x86_64.sh <container-id>:/home/
$ docker cp GitHubLab/ResearchWork <container-id>:/home/

镜像环境

# cd /home/   # or /root/
# bash ./Aanconda3-2023.03-Linux-x86_64.sh
# apt update
# apt install vim
# apt install wget
# vim ~/.bashrc
# source ~/.bashrc

配置文件 ~/.bashrc

# added by Anaconda3 installer
export PATH="/home/anaconda3/bin:$PATH"

https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
https://mirrors.aliyun.com/pypi/simple/tensorflow-gpu/

@eustomaqua
Copy link
Owner Author

eustomaqua commented Mar 16, 2024

实验环境
Python 3.8 miniconda3

# conda create -n enspi python=3.8
# source activate enspi
# pip list
# pip install -r requirements.txt
# python -m pytest tests/fair/test_manf_exp2.py

Docker 本地镜像

$ docker images
$ docker ps -a
$ docker commit <container-id> myexpt:init  #fairubuntu
$ docker save -o myexpt.tar myexpt

退出后重新进入

# exit
$ docker run -it myexpt:init /bin/bash
$ docker exec -it myexpt:init /bin/bash
$ cd /home
$ source activate enspi

https://zhuanlan.zhihu.com/p/348849578
如果想直接推去自己hub管理,镜像名改为your-hubname/mssql-2019-with-cimb:1.0
image vs. container cf1, cf2, cf3, cf4
fairgbm issue suggestion, docker-hub

@eustomaqua
Copy link
Owner Author

eustomaqua commented Mar 16, 2024

镜像制作 (Mac)
Dockerfile

# 设置基础映像
FROM --platform=linux/amd64 ubuntu:latest

# 安装Miniconda
RUN apt-get update && apt-get install -y wget
RUN apt-get update && apt-get install vim -y

本地机

$ # 进入目录
$ cd ~  # locate Dockerfile

$ #编译镜像(默认为latest)(注意结尾一定要加.)
$ docker build -t fairgbm .
$ #编译指定版本镜像(注意结尾一定要加.)
$ docker build -t fairgbm:1.0 .

$ # 查看本地镜像 镜像列表
$ docker images

环境配置 见下
文件传递

$ cd ~/Desktop
$ docker cp Miniconda3-py311_24.1.2-0-Linux-x86_64.sh <container-id>:/home
$ docker cp Miniconda3-py311_24.1.2-0-Linux-aarch64.sh <container-id>:/home
$ # docker run -it ubuntu

$ docker start <container-id>
$ docker rename <container-old-name> <new-name>
$ docker [stop][start] <container-id>  # 启动/停止

镜像备份 (Mac)

@eustomaqua
Copy link
Owner Author

eustomaqua commented Mar 16, 2024

环境配置 cont.
容器内安装

# apt-get update
# apt install vim
# apt install wget

# apt-get clean
# apt-get autoremove

# cd home && ls

# bash ./Miniconda3-py311_24.1.2-0-Linux-x86_64.sh
# bash ./Miniconda3-py311_24.1.2-0-Linux-aarch64.sh
# rm Miniconda3-py311_24.1.2-0-Linux-x86_64.sh

Do you accept the license terms? [yes|no]
>>> yes
Miniconda3 will now be installed into this location:
[/root/miniconda3] >>> /home/miniconda3
Do you wish to update your shell profile to automatically initialize conda?
This will activate conda on startup and change the command prompt when activated.
If you'd prefer that conda's base environment not be activated on startup,
   run the following command when conda is activated:
conda config --set auto_activate_base false
You can undo this by running `conda init --reverse $SHELL`? [yes|no]
[no] >>> no

配置运行环境

$ vim ~/.bashrc

# self-added by Anaconda3 installer
export PATH=/home/miniconda3/bin:$PATH

$ source ~/.bashrc
$ conda env list
$ conda create -n ensem python=3.8

其他
一些错误
Docker Error response from daemon, run -it-d 区别 run vs start,

下载文件
Miniconda3 Latest installer links by Python version, hash information
Anaconda3 Installing previous versions, All package lists

@eustomaqua
Copy link
Owner Author

eustomaqua commented Mar 31, 2024

容器使用
启动和暂停

$ docker ps -a

$ docker stop <container-id>
$ docker start <container-id>

$ docker exec -it <container-id> /bin/bash
root@<container-id>:/# exit

资源占用查询

$ docker stats --no-stream

查看 docker 容器使用的资源

@eustomaqua eustomaqua added help wanted Extra attention is needed and removed help wanted Extra attention is needed labels Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant