interbeing
3 min readOct 20, 2021

--

Build a Container Registery on alibaba cloud

Login into alibaba cloud with your account.

Create namespace

Create image repository

Select “local” if only use it to store image.

create credential for login to repository

Username is alibaba account name.

you shall able to login to registory now

on your client machine (if you client is on public internet)

sudo docker login --username=youusername@com registry.cn-hangzhou.aliyuncs.com

Create a Dockerfile on your client machine and tag it and push to registory.

ubuntu@t:~$ cat Dockerfile
FROM ubuntu:18.04
RUN apt-get update && \
apt-get -y install apache2
RUN echo 'Hello world' > /var/www/html/index.htmlRUN echo '. /etc/apache2/envvars' > /root/run_apache.sh && \
echo 'mkdir -p /var/run/apache2' >> /root/run_apache.sh && \
echo 'mkdir -p /var/lock/apache2' >> /root/run_apache.sh && \
chmod 755 /root/run_apache.sh
EXPOSE 80CMD /root/run_apache.shubuntu@t:~$ sudo docker build -t hello-world .
Sending build context to Docker daemon 190.8MB
Step 1/6 : FROM ubuntu:18.04
---> 5a214d77f5d7
Step 2/6 : RUN apt-get update && apt-get -y install apache2
---> Using cache
---> 96f9b3ec6703
Step 3/6 : RUN echo 'Hello world' > /var/www/html/index.html
---> Using cache
---> 4b892c71c0de
Step 4/6 : RUN echo '. /etc/apache2/envvars' > /root/run_apache.sh && echo 'mkdir -p /var/run/apache2' >> /root/run_apache.sh && echo 'mkdir
-p /var/lock/apache2' >> /root/run_apache.sh && chmod 755 /root/run_apache.sh
---> Using cache
---> 696c2e18b24f
Step 5/6 : EXPOSE 80
---> Using cache
---> 86cb3e83a4d8
Step 6/6 : CMD /root/run_apache.sh
---> Using cache
---> c489e68eb911
Successfully built c489e68eb911
Successfully tagged hello-world:latest
ubuntu@t:~$ sudo docker images --filter reference=hello-world
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest c489e68eb911 13 hours ago 198MB
ubuntu@t:~$ sudo docker tag c489e68eb911 registry.cn-hangzhou.aliyuncs.com/andydemo/test001:latest
ubuntu@t:~$ sudo docker push registry.cn-hangzhou.aliyuncs.com/andydemo/test001:latest
The push refers to repository [registry.cn-hangzhou.aliyuncs.com/andydemo/test001]
12f137e159a1: Layer already exists
59607830e2dd: Layer already exists
07c72d58d34d: Layer already exists
824bf068fd3d: Layer already exists
latest: digest: sha256:acb67e4651649434bb105f476459fe1c3bc699501351318633a6c380583dfc13 size: 1155

--

--