在hub.docker發(fā)布自己的image


前言:創(chuàng)建自己的docker image并上傳到hub.docker倉庫

??先注冊(cè)hub賬戶 https://hub.docker.com/
1.創(chuàng)建Dockerfile
2.構(gòu)建Image
3.打標(biāo)簽Image
4.登錄hub.docker
4.上傳Image

1.創(chuàng)建Dockerfile

這里以swoole環(huán)境為例子,創(chuàng)建一個(gè)自己的docker開發(fā)環(huán)境

#  基礎(chǔ)鏡像
FROM php:7.1

# 作者信息
MAINTAINER degree757 <degree757@qq.com>

# 環(huán)境變量
ENV SWOOLE_VERSION 1.10.3

# Timezone
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
    && echo 'Asia/Shanghai' > /etc/timezone

# 依賴
RUN apt-get update \
    && apt-get install -y \
        curl \
        wget \
        git \
        zip \
        libz-dev \
        libssl-dev \
        libnghttp2-dev \
        libpcre3-dev \
    && apt-get clean \
    && apt-get autoremove

# PDO extension
RUN docker-php-ext-install pdo_mysql

# Bcmath extension
RUN docker-php-ext-install bcmath

# Swoole extension
RUN wget https://github.com/swoole/swoole-src/archive/v${SWOOLE_VERSION}.tar.gz -O swoole.tar.gz \
    && mkdir -p swoole \
    && tar -xf swoole.tar.gz -C swoole --strip-components=1 \
    && rm swoole.tar.gz \
    && ( \
        cd swoole \
        && phpize \
        && ./configure --enable-mysqlnd --enable-openssl --enable-http2 \
        && make -j$(nproc) \
        && make install \
    ) \
    && rm -r swoole \
    && docker-php-ext-enable swoole

2.構(gòu)建Image

在Dockerfile目錄下,運(yùn)行構(gòu)建Image命令

?  docker build -t swoole . 

3.打標(biāo)簽Image

docker image ls查看當(dāng)前本地鏡像

?  docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
swoole              1.10                dbee969e838c        2 hours ago         425MB
php                 7.1                 8bbf0726af2d        3 weeks ago         358MB   
?  docker tag dbee969e838c degree757/swoole:1.10

給swoole鏡像打個(gè)標(biāo)簽 docker tag dbee969e838c degree757/swoole:1.10

  • degree757 是你們自己在hub.docker的ID
  • swoole:1.10 鏡像以及版本

??dbee969e838c是你們自己的IMAGE ID

4.登錄hub.docker

通過login命令登錄

?  docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: degree757
Password: 
Login Succeeded

4.上傳Image

推送本地鏡像到hub.docker,至此完畢

?  docker push degree757/swoole

總結(jié)

發(fā)布鏡像成功,開啟持續(xù)集成

https://hub.docker.com/

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容