前言:創(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ù)集成