2020-01-07 09:32:27 +00:00
|
|
|
# Docker
|
2020-01-07 09:22:41 +00:00
|
|
|
|
2020-01-07 11:14:08 +00:00
|
|
|
Dockerfile and compose files used as basis for service deployment.
|
2020-01-16 14:09:47 +00:00
|
|
|
|
2022-10-14 17:06:58 +00:00
|
|
|
## Prepare environment
|
2020-01-16 14:09:47 +00:00
|
|
|
|
|
|
|
```
|
2022-10-14 17:06:58 +00:00
|
|
|
registry=[registryUrl]
|
|
|
|
image=[imageName]
|
|
|
|
tag=[versionTag]
|
2020-01-16 14:09:47 +00:00
|
|
|
```
|
|
|
|
|
2023-06-26 11:27:07 +00:00
|
|
|
## Build image
|
2022-10-14 17:06:58 +00:00
|
|
|
|
2022-03-21 12:06:23 +00:00
|
|
|
Build the image with *latest* tag.
|
|
|
|
```
|
2022-10-14 17:06:58 +00:00
|
|
|
docker build -t $registry/$image $image
|
2022-03-21 12:06:23 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Tag the image with version.
|
|
|
|
```
|
2022-10-14 17:06:58 +00:00
|
|
|
docker tag $registry/$image $registry/$image:$tag
|
|
|
|
```
|
|
|
|
|
|
|
|
Test image locally
|
|
|
|
```
|
|
|
|
docker run --name test $registry/$image:$tag
|
2022-03-21 12:06:23 +00:00
|
|
|
```
|
|
|
|
|
2023-06-26 11:27:07 +00:00
|
|
|
## Push image
|
|
|
|
|
2022-03-21 12:06:23 +00:00
|
|
|
Login into docker registry (If it's the first time or you are not saving credentials).
|
2020-01-16 14:09:47 +00:00
|
|
|
```
|
2022-10-14 17:06:58 +00:00
|
|
|
docker login $registry
|
2020-01-16 14:09:47 +00:00
|
|
|
```
|
|
|
|
|
2022-03-21 12:06:23 +00:00
|
|
|
Push the *latest* image and version tag.
|
2020-01-16 14:09:47 +00:00
|
|
|
```
|
2022-10-14 17:06:58 +00:00
|
|
|
docker push $registry/$image
|
|
|
|
docker push $registry/$image:$tag
|
2020-01-16 14:09:47 +00:00
|
|
|
```
|
|
|
|
|
2020-01-24 10:55:05 +00:00
|
|
|
Logout from docker registry (If you don't logout, credentials will remain saved
|
|
|
|
in your home directory).
|
2020-01-16 14:09:47 +00:00
|
|
|
```
|
2022-10-14 17:06:58 +00:00
|
|
|
docker logout $registry
|
2020-01-16 14:09:47 +00:00
|
|
|
```
|