Lost data docker gitlab on local osx - macos

This is how I run GitLab with Docker:
Step 1. Launch a postgresql container
docker run --name gitlab-postgresql -d \
--env 'DB_NAME=gitlabhq_production' \
--env 'DB_USER=gitlab' --env 'DB_PASS=password' \
--volume /srv/docker/gitlab/postgresql:/var/lib/postgresql \
sameersbn/postgresql:9.4-12
Step 2. Launch a redis container
docker run --name gitlab-redis -d \
--volume /srv/docker/gitlab/redis:/var/lib/redis \
sameersbn/redis:latest
Step 3. Launch the gitlab container
docker run --name gitlab -d \
--link gitlab-postgresql:postgresql --link gitlab-redis:redisio \
--publish 10022:22 --publish 10080:80 \
--env 'GITLAB_PORT=10080' --env 'GITLAB_SSH_PORT=10022' \
--env 'GITLAB_SECRETS_DB_KEY_BASE=long-and-random-alpha-numeric-string' \
--volume /srv/docker/gitlab/gitlab:/home/git/data \
sameersbn/gitlab:8.4.2
However, when I restart or shutdown the computer, all previous data is gone.
Please help me, I am new to Docker and GitLab in Docker.

Your approach seems correct and I do not see why the volumes wouldn't persist your data. When you've restarted your computer, you can try to start the stopped containers using these commands:
docker start gitlab-postgresql
docker start gitlab-redis
docker start gitlab
By the way, I'd recommend using this docker-compose.yml file to setup your gitlab environent. Just download the file and run docker-compose up -d.

Related

How to launch graphite docker container locally?

I am following this wiki to setup some performance numbers for my testing I am doing. I needed to setup graphite to see my numbers.
So I ran this command as mentioned in the wiki on my mac -
docker run -d --name graphite -p 80:80 -p 2003-2004:2003-2004 -p 2023-2024:2023-2024 -p 8125:8125/udp -p 8126:8126 graphiteapp/graphite-statsd
Below is what I got:
> docker run -d --name graphite -p 80:80 -p 2003-2004:2003-2004 -p 2023-2024:2023-2024 -p 8125:8125/udp -p 8126:8126 graphiteapp/graphite-statsd
Unable to find image 'graphiteapp/graphite-statsd:latest' locally
latest: Pulling from graphiteapp/graphite-statsd
aad63a933944: Pull complete
9b6d24804914: Pull complete
5f9542cd4cb1: Pull complete
09c978daf42b: Pull complete
Digest: sha256:18fbffd024cd540c7a57febfaa38c3dc5513f05db2263300209deb2a8ecd923c
Status: Downloaded newer image for graphiteapp/graphite-statsd:latest
ac248794f9cdea3bd1ab65659ec321d0aa0111de3f151c5e206b6503202a35e3
Now I ran my program which is pushing my metrics to graphite and then I was trying to configure my grafana dashboard by launching grafana docker container with below command as shown in that same wiki:
docker run -d --name -p 3000:3000 grafana grafana/grafana
But I got an error once I executed above command:
> docker run -d --name -p 3000:3000 grafana grafana/grafana
Unable to find image '3000:3000' locally
docker: Error response from daemon: pull access denied for 3000, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
See 'docker run --help'.
This is the first time I am working with docker so have some issues setting it up and I have already installed docker on my mac. Any idea what is wrong here?
To explain the problem in your command.
Your command
docker run -d --name -p 3000:3000 grafana grafana/grafana
As you can see, --name, no value is specified and that's why it is picking up random value for the image. Use the below command. Meaning of the flags are
--name => Name of the container which is grafana in this case
-p => Publish a container's port(s) to the host, which is 3000:3000 over here
-d => Run container in background and print container ID
docker run -d -p 3000:3000 --name grafana grafana/grafana
Logs of the command:
docker run -d -p 3000:3000 --name grafana grafana/grafana
Unable to find image 'grafana/grafana:latest' locally
latest: Pulling from grafana/grafana
cbdbe7a5bc2a: Already exists
ed18d4ca725a: Pull complete
5ac007dea7db: Pull complete
33b8e7fbf663: Pull complete
09cd2fb04616: Pull complete
990c0b335bdb: Pull complete
Digest: sha256:4bbfcbf9372e1022bf51b35ec1aaab04bf46e01b76a1d00b424f45b63cf90967
Status: Downloaded newer image for grafana/grafana:latest
7748b112f5004a18144152ac7330749b83120914bb0ab0d3a7112ea16368bfa2
Just set --name grafana.
docker run -d --name grafana -p 3000:3000 grafana/grafana
Unable to find image 'grafana/grafana:latest' locally
latest: Pulling from grafana/grafana
cbdbe7a5bc2a: Already exists
ed18d4ca725a: Pull complete
....
....

Docker in window map between windows folder and linux folder

Am I able to map docker Linux container to windows folder?
docker run -d -p 80:80 -p 443:443 -v c:/docker/volumes/nginx/docker.sock:/tmp/docker.sock:ro --network nginx-proxy-network --ip 172.18.0.3 jwilder/nginx-proxy

install gitlab on Windows with Docker

I searched a lot and found that GitLab Community Edition is not installed on Windows so now I want to install it with the help of Docker. I do not know that is it possible and how I can do it ?
You need to install Docker for Windows.
Share drive for Docker (in Docker's settings > shared drives). For example, drive E:
Then, you need to create 3 directories on drive E: (e:\gitlab\config, e:\gitlab\logs, e:\gitlab\data)
From the Command Prompt, run:
docker run --detach --hostname gitlab.yourdomain.ru
--publish 443:443 --publish 80:80 --publish 22:22 --name gitlab
--restart always --volume e:\gitlab\config:/etc/gitlab
--volume e:\gitlab\logs:/var/log/gitlab
--volume e:\gitlab\data:/var/opt/gitlab gitlab/gitlab-ce:latest
That's it! You have now successfully run GitLab image.
Yes, you can run gitlab-ce on windows using Docker. First, make sure docker is installed on Windows, otherwise install it.
A detailed documentation for how to run gitlab using Docker is found under GitLab Docker images including how to access the web interface.
You can check gitlab documantation from Expose GitLab on different ports section.
Before starting the installation create 3 folder which names "config","data","logs" in a "gitlab" folder. And run your gitlab-ce image with docker run command.Gitlab should be running firstly.
Note that I will use 8082 port for gitlab server.You can change it with any port number.
1-open cmd and show your IP address.You need to look for the IPv4 Address in your network adapter :
ipconfig
2-Run your docker-ce image with this command :
docker run --detach --hostname YOUR-IP-ADRESS --publish 8082:8082 --publish 2282:22 --name gitlab --restart always --volume D:\DevOps\Gitlab/config:/etc/gitlab --volume D:\DevOps\Gitlab/logs:/var/log/gitlab --volume D:\DevOps\Gitlab/data:/var/opt/gitlab gitlab/gitlab-ce:latest
3-In docker terminal(in docker gui application press to "cli" buton) go here :
cd etc/gitlab
nano gitlab.rb
4-Go to end of file at gitlab.rb and write these lines :
external_url "http://your-ip-address:8082"
gitlab_rails['gitlab_shell_ssh_port'] = 2282
5-After save and close to gitlab.rb file enter this code for reconfiguration:
gitlab-ctl reconfigure
6-Remove your docker container and run with this command again:
docker run --detach --hostname YOUR-IP-ADRESS --publish 8082:8082 --publish 2282:22 --name gitlab --restart always --volume D:\DevOps\Gitlab/config:/etc/gitlab --volume D:\DevOps\Gitlab/logs:/var/log/gitlab --volume D:\DevOps\Gitlab/data:/var/opt/gitlab gitlab/gitlab-ce:latest
I found the solution here, there is a issue related with volumes when installing in Docker for Windows
https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/2280
Use the following docker-compose file:
web:
image: 'gitlab/gitlab-ce:13.7.1-ce'
restart: always
hostname: 'localhost'
environment:
GITLAB_OMNIBUS_CONFIG: |
#KO gitlab_rails['initial_root_password'] = 'adminadmin'
gitlab_rails['gitlab_shell_ssh_port'] = 2222
external_url 'http://localhost'
ports:
- '8185:80'
- '1443:443'
- '2222:22'
volumes:
- '/srv/gitlab/config:/etc/gitlab'
- '/srv/gitlab/logs:/var/log/gitlab'
#important here: do not mount /var/opt/gitlab but /var/opt as stated here:
# https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/2280
- '/srv/gitlab/data:/var/opt'
Do (cygwin) docker ps | grep gitlab until status (healthy) is shown, then open a browser at http://localhost:8185
If you are not asked the first time to change root password,
set it like this (cygwin):
docker exec -it $(docker ps | grep gitlab | awk '{print $1}') bash
root#dev:/# gitlab-rails console -e production
--------------------------------------------------------------------------------
Ruby: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
GitLab: 13.12.5 (f37a805b0b4) FOSS
GitLab Shell: 13.18.0
PostgreSQL: 12.6
--------------------------------------------------------------------------------
Loading production environment (Rails 6.0.3.6)
irb(main):001:0> user = User.where(id: 1).first => #<User id:1 #root>
irb(main):002:0> user.password = 'adminadmin' => "adminadmin"
irb(main):003:0> user.password_confirmation = 'adminadmin' => "adminadmin"
irb(main):004:0> user.save Enqueued ActionMailer::MailDeliveryJob (Job ID: d5dce701-2a79-4bed-b0a4-2abb877c2081) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", {:args=>[#<GlobalID:0x00007f621582b210 #uri=#<URI::GID gid://gitlab/User/1>>]}
=> true
irb(main):005:0> exit
Then login, create a user, give him a first password, login with it update password, create a project, and use project's git url rather than http since the use of a port seems to generate some trouble with the http url. Generating a public private/key and registering the public on in gitlab might be required

Link two docker containers on Windows 10

I have my mongo container running:
docker run --security-opt=seccomp:unconfined -p 27017:27017 -p 28017:28017 --name mong --rm mong --link myapp
and my app
docker run --rm -ti --security-opt=seccomp:unconfined -p8080:8080 --name myapp --link mong --expose 8080
When I run docker port myapp
8080/tcp -> 0.0.0.0:8080
And docker port mong get following:
27017/tcp -> 0.0.0.0:27017
28017/tcp -> 0.0.0.0:28017
However myapp doesn't see mong ports. When I run docker run --rm -ti --security-opt=seccomp:unconfined -p8080:8080 --name myapp --link mong --expose 8080 with --net=host flag myapp starts to see mong container ports, but stops expose 8080.
How to fix it? What is wrong?
If you want to link two or more containers, you can use network.
First create a network:
$ docker network create --driver bridge dev_network
Now run the both container with --net=dev_network
Container 1
$ docker run --security-opt=seccomp:unconfined -p 27017:27017 -p 28017:28017 --name mong --rm mong --net=dev_network
Container 2
docker run --rm -ti --security-opt=seccomp:unconfined -p 8080:8080 --name myapp --net=dev_network
You can now access the containers inside the network with container name.

Passing Elasticsearch and Kibana config file to docker containers

I have found a docker image devdb/kibana which runs Elasticsearch 1.5.2 and Kibana 4.0.2. However I would like to pass into this docker container the configuration files for both Elasticsearch (i.e elasticsearch.yml) and Kibana (i.e config.js)
Can I do that with this image itself? Or for that would I have to build a separate docker container?
Can I do that with this image itself?
yes, just use Docker volumes to pass in your own config files
Let say you have the following files on your docker host:
/home/liv2hak/elasticsearch.yml
/home/liv2hak/kibana.yml
you can then start your container with:
docker run -d --name kibana -p 5601:5601 -p 9200:9200 \
-v /home/liv2hak/elasticsearch.yml:/opt/elasticsearch/config/elasticsearch.yml \
-v /home/liv2hak/kibana.yml:/opt/kibana/config/kibana.yml \
devdb/kibana
I was able to figure this out by looking at your image Dockerfile parents which are: devdb/kibana→devdb/elasticsearch→abh1nav/java7→abh1nav/baseimage→phusion/baseimage
and also taking a peek into a devdb/kibana container: docker run --rm -it devdb/kibana find /opt -type f -name *.yml.
Or for that would I have to build a separate docker container?
I assume you mean build a separate docker image?. That would also work, for instance the following Dockerfile would do that:
FROM devdb/kibana
COPY elasticsearch.yml /opt/elasticsearch/config/elasticsearch.yml
COPY kibana.yml /opt/kibana/config/kibana.yml
Now build the image: docker build -t liv2hak/kibana .
And run it: docker run -d --name kibana -p 5601:5601 -p 9200:9200 liv2hak/kibana

Resources