Doug Fir
Doug Fir

Reputation: 21232

Hello world with gitlab ce docker container running on local ubuntu

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?

Upvotes: 0

Views: 2739

Answers (1)

Alexey R.
Alexey R.

Reputation: 8676

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.

  1. 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 of srv/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.
  2. Taking the above in the account I would suggest to create a separate folder (say my-gitlab) and create the folders config, logs and data inside that folder. They are to be empty but will be filled on Gitlab start.
  3. Put your docker-compose.yaml to my-gitlab and switch to that folder.
  4. 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 and 443 so I expose all the ports to what I have free by the moment
  • At this part http://localhost the http:// is important. If you set https:// 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 call docker-compose up from a proper place.

So in my case I could successfully connect to http://localhost:54321.

Upvotes: 4

Related Questions