docker 命令备忘

2025年12月31日15:12:45 发表评论 7 views

 

 

docker

 

# 查看Ubuntu版本:

root@localhost:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04 LTS
Release: 18.04
Codename: bionic

root@localhost:~# cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
root@localhost:~#

# docker 版本:
root@localhost:~# docker -v
Docker version 19.03.7, build 7141c199a2

# 查看现有镜像:
docker images

# 查看正在运行的镜像:
docekr ps

# 下载镜像:
docker pull python:3.12-slim

# 进入容器开始工作:
docker run --rm -it \
-v /data/work:/work \
-w /work \
python:3.12-slim bash

# 直接调用内部环境处理外部脚本:
docker run --rm \
-v /data/work:/work \
-w /work \
python:3.12-slim \
python your_script.py

# 进度条报错可以用:
pip install --progress-bar off pandas

 

镜像打包并复用

#提交: 
docker commit f1c388a5c12d python312-pandas:1.0
# 检查: 
docker images | grep python312-pandas 
# 导出为tar包: 
docker save python312-pandas:1.0 -o python312-pandas.tar 
# 新机器直接用: 
docker load -i python312-pandas.tar 
# 确认: 
docker images | grep python312-panda 
# 直接运行或参考上面的: 
docker run --rm -it python312-pandas:1.0 python -c "import pandas as pd; print(pd.__version__)"

 

 

 

其他:


 

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: