Setting up private docker registry with a frontend - docker

I am trying to set up a docker registry with a frontend and am having problems
I use the following docker compose, and am unable to see the repos that are present in the registry. I assume the most basic setup as follows:
web:
container_name: registry-frontend
image: hyper/docker-registry-web
ports:
- "8085:8080"
links:
- registry
environment:
REGISTRY_HOST: registry
registry:
container_name: registry
image: registry:2
ports:
- 5000:5000
environment:
REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY: /registry
volumes:
- /data/docker-registry/:/registry
When I check for repositories present in the registry service, I can see the repos
I ran the following command:
http://<host>:5000/v2/_catalog
and got the following result
{"repositories":["baseimage","myfirstimage"]}
However, these are not visible in the frontend. Essentially the integration does not seem to be working. Can anyone help out in figuring out what could be wrong?

Related

Running an environment with docker-compose

I have a docker-compose.yml file like so:
version: "3.8"
services:
app:
build:
context: .
dockerfile: Dockerfile
image: darajava/audio-diary
ports:
- 80:3001
volumes:
- .:/app
- "/app/node_modules"
depends_on:
- db
container_name: "soliloquy_express"
db:
image: mariadb:latest
restart: always
environment:
- MYSQL_DATABASE=soliloquy
- MYSQL_USER=soliloquy
- MYSQL_PASSWORD=password
- MYSQL_ROOT_PASSWORD=password
volumes:
- ../db_data:/var/lib/mysql
container_name: "soliloquy_db"
I'm planning to add an nginx service here too.
I use
docker-compose build
and
docker-compose push
to push to Docker Hub, which I can pull from (from my EC2 instance) using:
docker pull darajava/audio-diary:latest
However, when I run that image, it only runs the app service (I think).
using
docker-compose pull darajava/audio-diary:latest
does not work and leads to an error regarding a missing docker-compose.yml file.
So I have 2 questions:
Is there a way I can pull a whole docker-compose config, with app, db, and other services and pull and run it on my EC2 instance just by pulling from Docker Hub? or do I have the wrong use case for Docker Compose?

How to properly run an application with docker compose using docker hub

As far as I understand, only images can be uploaded to the docker hub, which then need to be spooled, and can be launched via docker run. But what if I have several images that I run through docker compose? I have a site on next.js and nginx. There is such docker-compose.yml
version: '3'
services:
nextjs:
build: ./
networks:
- site_network
nginx:
build: ./.docker/nginx
ports:
- 80:80
- 443:443
networks:
- site_network
volumes:
- /etc/ssl/certs:/etc/ssl/certs:ro
depends_on:
- nextjs
networks:
site_network:
driver: bridge
If I do a git clone of the repository on the server, and do docker-compose up --build -d, then everything works. I want to automate everything via gitlab ci/cd. I found an article that describes the procedure for installing a runner on a server + a description of the .gitlab-ci.yml file that creates an image, uploads it to the docker hub, and then downloads it on the server and launches it using docker run. Here I see this approach: in gitlab-ci.yml I make several images that I upload to the hub. Next, I upload a file from the docker-compose.yml repository to the server, which will have the following structure:
version: '3'
services:
nextjs:
image: registry.gitlab.com/path_to_project/next:latest
networks:
- site_network
nginx:
image: registry.gitlab.com/path_to_project/nginx:latest
ports:
- 80:80
- 443:443
networks:
- site_network
volumes:
- /etc/ssl/certs:/etc/ssl/certs:ro
depends_on:
- nextjs
networks:
site_network:
driver: bridge
How correct is this approach? Maybe there is a more reliable and better way? Advanced stack (kubernetes, etc.) not yet considered, I want to learn all the basics first before moving on.

How to tag docker compose image with ECR url?

I have a Docker compose file setup which I am trying to push to ECR ( Elastic Container Registry ).
In order for me to Push it to ECR, I need to tag it with the URL of my ECR repo which is provided by AWS.
My docker-compose.yml file looks like this :-
version: '2'
services:
prometheus:
image: prom/prometheus
ports:
- '9090:9090'
container_name: prometheus
restart: always
volumes:
- './prometheus.yml:/etc/prometheus/prometheus.yml'
grafana:
image: grafana/grafana
ports:
- '3000:3000'
container_name: grafana
restart: always
depends_on:
- prometheus
volumes:
- './grafana.ini:/etc/grafana/grafana.ini'
But the AWS instructions tell me to build my app first using docker build ( I can do docker-compose up -d to build with docker compose ) and then it says to tag it with the URL of the registry.
Something like :-
docker tag myapp:url.ecr.us-west-1.amazonaws.com/myapp:latest
Where myapp is the name of the repo.
So I need a little bit of guidance as to how i can use this tag in my docker compose file?
Thank you.
You're looking to extend upon the image attribute. If you append a colon to the image, whatever comes after is built as the tag. Though note that this must be used in conjunction with build.
From the docs:
If you specify image as well as build, then Compose names the built image with the webapp and optional tag specified in image:
build: ./dir
image: webapp:tag
This results in an image named webapp and tagged tag, built from ./dir.
As such, you're likely looking for:
version: '2'
services:
prometheus:
build: ./dir
image: prom/prometheus:url.ecr.us-west-1.amazonaws.com/prom/prometheus:latest
ports:
- '9090:9090'
container_name: prometheus
restart: always
volumes:
- './prometheus.yml:/etc/prometheus/prometheus.yml'
grafana:
build: ./dir
image: grafana/grafana:url.ecr.us-west-1.amazonaws.com/grafana/grafana:latest
ports:
- '3000:3000'
container_name: grafana
restart: always
depends_on:
- prometheus
volumes:
- './grafana.ini:/etc/grafana/grafana.ini'
I tagged the running containers using :-
docker tag Image url.ecr.us-west-1.amazonaws.com/myapp:latest
And then i was able to do a docker push to ECR.

Github Actions Workflow: Unable to connect to the custom-built Docker Container's port via image://container-name:port/rest/of/path

My goal: I'll commit a PR for a repo that triggers a GA Workflow. This includes building the Docker image for that repo along with other images.
All of their images are built by checking out their repos b/c my team wants to avoid pulling their images. Thus, I cannot use the service-containers workflow setup since it requires pulling images from Docker Hub or AWS ECR.
When running my GA Workflow, after docker-composing my containers, I'm unable to get feeds from my Docker Container's url (image://container-name:port/rest/of/path). Instead, I see this error ECONNREFUSED 127.0.0.1:80
Other attempts:
Using http:/localhost:port/rest/of/path. Got same error ECONNREFUSED 127.0.0.1:80
Using the Docker Container's IP http:docker.ip:port/rest/of/path. Got different error Error: connect EHOSTUNREACH 172.18.0.6:8088 at TCPConnectWrap.afterConnect
Create a Docker image of my tests, adding to the docker-compose file, and repeating the above steps. Same errors.
If this provides more context, I added a template of my docker-compose.yml below. Each of them except the db images have a repo. They depend on each other as follows
Containers: C -> B + A -> db
*tests run against C
I start my GA workflow like below:
Start a PR for C and it triggers the GA Workflow
Checkout each of the above repos (except db, that’s public)
Build each of their images and then docker-compose up
Checkout my tests repo and run them against the C’s localhost url's feeds (C://C:3333/rest/of/path).
version: "3"
services:
db:
image: mongo:latest
container_name: db
db-seed:
image: mongo:latest
container_name: db_seed
links:
- db
volumes_from:
- db
command:
/import.sh
A:
image: ecr-aws/A
container_name: api
ports:
- 1111:1111
env_file:
- 'A/.env'
depends_on:
- db
B:
image: ecr-aws/B
container_name: B
ports:
- 2222:2222
env_file:
- 'B/.env'
depends_on:
- db
C:
image: ecr-aws/C
container_name: C
ports:
- 3333:3333
env_file:
- 'C/.env'
depends_on:
- A

docker registry frontend (konradkleine/docker-registry-frontend) getting error when clicked on repository and also docker images are not seen

I am using docker registry frontend (konradkleine/docker-registry-frontend), when i browser the repository i am getting following error(attached image) when clicked on repository and also docker images are not seen in UI. Below is the dockercompose file which I am using.
---
version: '3'
services:
docker-registry:
container_name: docker-registry
image: registry:2
ports:
- 5000:5000
restart: always
volumes:
- ./volume:/var/lib/registry
docker-registry-ui:
container_name: docker-registry-ui
image: konradkleine/docker-registry-frontend:v2
links:
- docker-registry:docker-registry
ports:
- 8080:80
environment:
ENV_DOCKER_REGISTRY_HOST: docker-registry
ENV_DOCKER_REGISTRY_PORT: 5000
Please open an issue here, so we can keep track of it, okay? https://github.com/kwk/docker-registry-frontend/issues/new
Also, please have a look at this document: https://github.com/kwk/docker-registry-frontend/tree/v2/example-setup to see if it solves the problem.
Related to this issue probably: https://github.com/kwk/docker-registry-frontend/issues/20
Speculated solution is to add link in UI section (service:env_variable) as:
links:
- docker-registry:docker-registry
I have same problem with (latest) registry and konradkleine (v2) registry-frontend.
Button Browse Repositories directs to the port where registry frontend is running.
In my case i have access to the registry-frontend from:
https://192.168.1.105:31652/home
And button Browse Repositories try redirect from:
https://192.168.1.105:31652/repositories/20
to
https://192.168.1.105:31652/v2/_catalog?n=20&last=
but this resource is available at:
192.168.1.105:5000/v2/_catalog?n=20&last=
in effect i receive:
GET https://192.168.1.105:31652/v2/_catalog?n=20&last= 503 (Service Unavailable)

Resources