Ucloud上线了Cube,用于运行docker镜像,目前属于免费公测阶段。官方提供了一些镜像,也可以使用自己的镜像。下面介绍如何上传并使用自定义镜像。
首先对本地的docker镜像打包上传。由于Cube默认没有配置外网IP(需要收费),所以镜像需要设置内网的源用于安装、更新软件。以下以ubuntu20.04为例介绍操作方法。
1、拉取镜像并运行;

2、修改源,替换为以下内容,ubuntu20.04源默认代号为focal;
deb http://xxg.mirrors.ucloud.cn/ubuntu/ focal main restricted universe multiverse
deb-src http://xxg.mirrors.ucloud.cn/ubuntu/ focal main restricted universe multiverse
deb http://xxg.mirrors.ucloud.cn/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://xxg.mirrors.ucloud.cn/ubuntu/ focal-updates main restricted universe multiverse
deb http://xxg.mirrors.ucloud.cn/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://xxg.mirrors.ucloud.cn/ubuntu/ focal-backports main restricted universe multiverse
deb http://xxg.mirrors.ucloud.cn/ubuntu/ focal-security main restricted universe multiverse
deb-src http://xxg.mirrors.ucloud.cn/ubuntu/ focal-security main restricted universe multiverse
deb http://xxg.mirrors.ucloud.cn/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://xxg.mirrors.ucloud.cn/ubuntu/ focal-proposed main restricted universe multiverse
3、退出docker并打包容器为镜像,其中的ubuntu,标签为20200823即为打包的镜像;

4、在Ucloud新建容器镜像库并上传,该镜像库的名称可自定义,也可选是否公开;
docker login uhub.service.ucloud.cn -u user@ucloud.cn
其中user@ucloud.cn为账户名,改为自己账户;
docker tag {本地镜像名} uhub.service.ucloud.cn/{已创建镜像仓库}/{镜像}:tag
docker push uhub.service.ucloud.cn/{已创建镜像仓库}/{镜像}:tag


5、在Cube新建容器并使用该镜像,注意需设置启动参数为/sbin/init;


6、启动容器并登陆;
