docker镜像制作
2023年6月21日大约 1 分钟
docker镜像制作
参考
准备工作
已安装Theia为例
https://github.com/eclipse-theia/theia/blob/master/doc/Developing.md#prerequisites
docker pull centos:latest
docker run -itd --name theia --network=host --entrypoint=init --privileged=true centos:latest /bin/bash
# 查看容器id
docker ps -a
#b3fe83251cc9 centos:latest "init /bin/bash" About a minute ago theia
#进入容器
docker exec -it b3fe83251cc9 /bin/bash
#安装nvm
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash
echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.bashrc
echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm' >> ~/.bashrc
source ~/.bashrc
#安装git
yum install -y git
#安装python3
#https://blog.csdn.net/weixin_41887201/article/details/124206113
#编译过程会用到C++17,CentOS7默认带的是GCC 4.8.5,支持不了的,至少得GCC5以上的版本,因此要升级GCC
yum install centos-release-scl
yum install devtoolset-9-toolchain
scl enable devtoolset-9 bash
echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile
yum install libX11-devel.x86_64 libxkbfile-devel.x86_64 libsecret-devel -y
#如果libxkbfile-devel无法安装
dnf --enablerepo=powertools install libxkbfile-devel
git clone https://github.com/eclipse-theia/theia \
&& cd theia \
&& yarn \
&& yarn download:plugins \
&& yarn browser build \
&& yarn browser start
https://zhuanlan.zhihu.com/p/381780183
https://www.yisu.com/zixun/631644.html
使用docker commit制作镜像
docker commit <container的ID> <新的image_name>
#使用docker commit将当前容器打包成镜像
docker commit b3fe83251cc9 theia_webide
#将镜像制作成包
docker save -o theia_webide.tar theia_webide
#加载恢复镜像
docker load -i theia_webide.tar
#基于镜像启动
docker run -itd -p 8080:8080 theia_webide
dockerfile打包镜像
docker build [-f 指定Dockerfile所在路径与文件名] -t 生成的镜像名:标签名 .
docker build -f ./Dockerfile -t oorzc/theia-https:latest .
登录docler 推送仓库
docker login -u 用户名 -p 密码
docker login -u name -p password
docker tag 镜像id 用户名/镜像名:版本号
docker tag bec83a552a74 oorzc/theia:latest
推送到docker仓库
docker push oorzc/theia:latest