问题
I would like to run the docker image for gitlab community edition locally on my ubuntu laptop.
I am following this tutorial.
Currently there i already another app running on localhost so I changed the ports in docker -compose.
What I currently have: I'm in a directory I created called 'gitlab_test'. I have set a global variable per the instructions echo $GITLAB_HOME /srv/gitlab
.
I pulled the ce gitlab image docker pull store/gitlab/gitlab-ce:11.10.4-ce.0
Then, in the gitlab_test directory I added a docker-compose file:
web:
image: 'gitlab/gitlab-ce:latest'
restart: always
hostname: 'localhost'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'https://gitlab.example.com'
ports:
- '8080:8080'
- '443:443'
- '22:22'
volumes:
- '/srv/gitlab/config:/etc/gitlab'
- '/srv/gitlab/logs:/var/log/gitlab'
- '/srv/gitlab/data:/var/opt/gitlab'
I am unsure if I need to put 'localhost' in place of hostname and external url parameters. I tried that and as is and in each case I cannot see anything happen. I was expecting a web interface for gitlab at localhost:8080.
Tried docker-compose up
and the terminal ran for a while with a bunch of output. There's no 'done' message (perhaps because I did not use -d?) but when I visit localhost:8080 I see no gitlab interface.
How can I run the gitlab ce container?
回答1:
If you want to use different port you should not change your "container port". Only the host port you are exposing your container port to. So instead of:
ports:
- '8080:8080'
- '443:443'
- '22:22'
You should have done:
ports:
- '8080:80'
- '443:443'
- '22:22'
Which means you expose the internal container port 80
(which you cannot change) to your host port 8080
.
UPD: I started this service locally and I think there are few things except ports to consider.
- You should create
$GITLAB_HOME
folders (by this I mean that there is no need to register environment variable but rather to create set of dedicated folders). You take this'/srv/gitlab/config:/etc/gitlab'
from example but this basically means "take content ofsrv/gitlab/config
and mount it to the path/etc/gitlab
" inside the container. I believe the paths like/srv/gitlab/config
do not exist at your host. - Taking the above in the account I would suggest to create a separate folder (say
my-gitlab
) and create the foldersconfig
,logs
anddata
inside that folder. They are to be empty but will be filled on Gitlab start. - Put your
docker-compose.yaml
tomy-gitlab
and switch to that folder. - Run
docker-compose up
from that folder. Do not use-d
flag so that you're not detaching and can see if errors happen.
Below is my docker-compose.yaml
with some explanation:
web:
image: 'gitlab/gitlab-ce:latest'
restart: always
hostname: 'localhost'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://localhost'
ports:
- '54321:80'
- '54443:443'
- '5422:22'
volumes:
- './config:/etc/gitlab'
- './logs:/var/log/gitlab'
- './data:/var/opt/gitlab'
Explanation:
- I have my local services running at
80
,8080
,22
and443
so I expose all the ports to what I have free by the moment - At this part
http://localhost
thehttp://
is important. If you sethttps://
Gitlab attempts to request SSL certificate for your domain at Letsencrypt. To make this you have to have public domain and some sort of port configuration. - Volumes are mounted through
.
(current directory) so that it is important to have consistent structure and calldocker-compose up
from a proper place.
So in my case I could successfully connect to http://localhost:54321
.
来源:https://stackoverflow.com/questions/65169038/hello-world-with-gitlab-ce-docker-container-running-on-local-ubuntu