Aşağıdaki adımları takip ederek bir docker imajını Docker Hub'a gönderme işlemini yapabilirsiniz.


Docker Hub hesabı yaratma


Bir hesap yaratmak için Docker Hub adresine gidin.


Uygulama yapısı


hello$ tree
.
├── app
│ ├── a.php
│ └── b.php
└── docker
├── docker-compose.yml
├── .env
└── php
└── Dockerfile

Dosyalar


a.php


echo 'Hello a'.PHP_EOL;

b.php


echo 'Hello b'.PHP_EOL;

Dockerfile


FROM php:7.2-cli

RUN echo ${HOME}

CMD tail -f /dev/null

docker-compose.yml


version: '3'

services:

php:
build:
context: ./php
image: inanzzz/hello
hostname: php
volumes:
- ../app:/app:rw
working_dir: /app

.env


COMPOSE_PROJECT_NAME=hello

Docker imaj yaratılması


Yerel ortamınızda bir Docker imajı oluşturduğunuzu varsayalım. Docker compose hello$ docker-compose up -d komutunu kullanarak basit bir PHP-CLI uygulaması yarattım. Sonuç aşağıdaki gibidir.


$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
inanzzz/hello latest 72b7a2f74c24 12 minutes ago 368MB
php 7.2-cli 71c6a3058357 6 days ago 368MB

$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5353e38a3b60 inanzzz/hello "docker-php-entrypoi…" 12 minutes ago Up 12 minutes hello_php_1

$ docker network ls
NETWORK ID NAME DRIVER SCOPE
3490cb99ced3 hello_default bridge local

Dokcer Hub login


$ docker login
Username: inanzzz
Password:

Login Succeeded

Gönderme işlemi


$ docker push inanzzz/hello:latest
The push refers to repository [docker.io/inanzzz/hello]
1704ec493095: Mounted from library/php
2ced8dda1e70: Mounted from library/php
latest: digest: sha256:123b7038fc8c450332090de16a71fb82f5b3d03ec89e4c11be9ffe9312912345 size: 2202

Etiketleme


İsterseniz, imajı özel olarak etiketleyebilir ve etiketlenmiş olan bu versiyonu gönderebilirsiniz.


$ docker tag inanzzz/hello:latest inanzzz/hello:0.0.1

$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
inanzzz/hello 0.0.1 72b7a2f74c24 35 minutes ago 368MB
inanzzz/hello latest 72b7a2f74c24 35 minutes ago 368MB

$ docker push inanzzz/hello:0.0.1
The push refers to repository [docker.io/inanzzz/hello]
1704ec493095: Layer already exists
2ced8dda1e70: Layer already exists
0.0.1: digest: sha256:123b7038fc8c450332090de16a71fb82f5b3d03ec89e4c11be9ffe93129c1234 size: 2202

Sonuç