간단하게 Git 서버가 필요해서 떠오른 GitLab을 어떻게 하면 한방에 설치할 수 있을지 연구하다가... ^^

최종적으로는 GitLab을 Docker 기반으로 실행을 하고 싶어서 이것 저것 알아보았다.

 

 

그런데, 이번에도 느낀 것이지만 개발환경(Development Environment)과 관련된 도구들은

막상 알게되면 그리 어렵지도 않고 별것도 아닌데 그 조금을 알아내기가 쉽지 않다.

 

Docker도 그렇고 GitLab도 그런 것 같다.

막상 알게 되면 그닥 어려운 애들이 아닌데 내가 필요한 것들을 알아내기가 쉽지는 않다.

 

내가 블로그를 시작한 이유처럼... 내가 알아낸 것들을 최대한 쉽게 많은 사람들에게 공유! 공유! 파이팅!!

 

 

 

 

1. Docker 설치하기

   - http://www.whatwant.com/825

 

 

 

2. 기존 Server SW 제거

   - 포트 충돌 방지를 위해서 기존에 해당 포트들을 사용하는 것들이 있으면 제거(?) 하자

   - 기본 포트는 [ 443, 80, 22 ] 이다.

   - 필자는 22번 SSh Server가 있어서 삭제를 진행했었다.

 

$ sudo apt-get purge openssh-server

 

 

 

3. Docker 실행

   - docker 설치 잘 되어있고, 포트 충돌날 것들 없앴고... 준비는 모두 끝났다.

   - 그냥 실행 확 해버리면 알아서 이미지 내려받고 알아서 잘 실행한다.

 

$ sudo docker run --detach --hostname gitlab.example.com --publish 443:443 --publish 80:80 --publish 22:22 --name gitlab --restart always --volume /srv/gitlab/config:/etc/gitlab --volume /srv/gitlab/logs:/var/log/gitlab --volume /srv/gitlab/data:/var/opt/gitlab gitlab/gitlab-ce:latest

 

   - 위에 작성된 옵션들을 잘 해석해보기 바란다. GitLab을 운영하기 위한 많은 것들이 녹아들어 있다.

   - 아래와 같은 옵션도 넣을 수 있다는 것을 참고하기 바란다(필요에 따라).

 

-e 'GITLAB_SSH_PORT=10022' -p 10022:22 -v /var/run/docker.sock:/run/docker.sock -v $(which docker):/bin/docker -v /home/swc/gitlab/data:/home/git/data -e 'GITLAB_HOST=git.site.net' -e 'GITLAP_TIMEZONE=UTC+9' -e 'GITLAB_EMAIL=git@git.site.net' -e 'SMTP_ENABLED=true' -e 'SMTP_DOMAIN=site.net' -e 'SMTP_HOST=123.234.345.456' -e 'SMTP_PORT=25' -e 'SMTP_OPENSSL_VERIFY_MODE=none' -e 'SMTP_AUTENTICATION=none' -e 'LDAP_ENABLED=true' -e 'LDAP_HOST=ldap.site.net' -e 'LDAP_PORT=636' -e 'LDAP_UID=uid' -e 'LDAP_METHOD=ssl' -e 'LDAP_BASE=ou=People,dc=swc,dc=site,dc=net' gitlab/gitlab-ce:latest

 

 

 

4. Login

   - http://localhost  접속하면 된다.

      • username: root

      • password: 5iveL!fe

 

 

 

파이팅!

 

반응형

 

Docker를 처음 접했을 때에 필자는 VirtualBox의 대용품으로만 생각했다.

 

온전한 가상환경이 아닌

부분적인 가상환경을 제공함으로써 성능저하 없이 사용할 수 있게 해주는 놈이라고만 생각했던 것이다.

 

하지만, Docker를 알아가면 알아갈 수록

Docker의 가치는 솔루션의 훌륭한 배포 플랫폼이라는 것에 있는 것 같다.

 

 

일단, 지금 여기에서 알아보고자 하는 것을 보면,,,

Dockerfile이라는 것은 이미지를 어떻게 생성하면 되는지를 적어놓은 파일이다.

 

아래는 MySQL 을 배포하기 위한 Dockerfile 내용이다. 내용을 살펴보면 Dockerfile이라는 것이 뭔지 보일 것이다.

   - https://hub.docker.com/_/mysql/

 

FROM debian:jessie

# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
RUN groupadd -r mysql && useradd -r -g mysql mysql

RUN mkdir /docker-entrypoint-initdb.d

# FATAL ERROR: please install the following Perl modules before executing /usr/local/mysql/scripts/mysql_install_db:
# File::Basename
# File::Copy
# Sys::Hostname
# Data::Dumper
RUN apt-get update && apt-get install -y perl pwgen --no-install-recommends && rm -rf /var/lib/apt/lists/*

# gpg: key 5072E1F5: public key "MySQL Release Engineering <mysql-build@oss.oracle.com>" imported
RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys A4A9406876FCBD3C456770C88C718D3B5072E1F5

ENV MYSQL_MAJOR 5.7
ENV MYSQL_VERSION 5.7.10-1debian8

RUN echo "deb http://repo.mysql.com/apt/debian/ jessie mysql-${MYSQL_MAJOR}" > /etc/apt/sources.list.d/mysql.list

# the "/var/lib/mysql" stuff here is because the mysql-server postinst doesn't have an explicit way to disable the mysql_install_db codepath besides having a database already "configured" (ie, stuff in /var/lib/mysql/mysql)
# also, we set debconf keys to make APT a little quieter
RUN { \
echo mysql-community-server mysql-community-server/data-dir select ''; \
echo mysql-community-server mysql-community-server/root-pass password ''; \
echo mysql-community-server mysql-community-server/re-root-pass password ''; \
echo mysql-community-server mysql-community-server/remove-test-db select false; \
} | debconf-set-selections \
&& apt-get update && apt-get install -y mysql-server="${MYSQL_VERSION}" && rm -rf /var/lib/apt/lists/* \
&& rm -rf /var/lib/mysql && mkdir -p /var/lib/mysql

# comment out a few problematic configuration values
# don't reverse lookup hostnames, they are usually another container
RUN sed -Ei 's/^(bind-address|log)/#&/' /etc/mysql/my.cnf \
&& echo 'skip-host-cache\nskip-name-resolve' | awk '{ print } $1 == "[mysqld]" && c == 0 { c = 1; system("cat") }' /etc/mysql/my.cnf > /tmp/my.cnf \
&& mv /tmp/my.cnf /etc/mysql/my.cnf

VOLUME /var/lib/mysql

COPY docker-entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

EXPOSE 3306
CMD ["mysqld"]

 

여기에서 Dockerfile의 문법에 대해서 설명을 하지는 않겠다.

하지만, 이 포스팅을 보시는 분이라면 대강 어떤 내용인지 알 수 있을 것이다.

 

 

이걸 잘 이용하면 재미있는 작품이 많이 나올 것만 같은 느낌인데.... 오홋~ ^^

 

 

반응형


Docker의 인기에 비해서 아직 내 주위의 사람들이 많이 사용하지 않는 이유는...?!

설치 과정이 편하지 않기 때문이라고 생각한다! 어려운게 아니라 귀찮다!


물론 공식 홈페이지에 너무나 잘 나와있다.

- https://docs.docker.com/engine/installation/ubuntulinux/



공식 홈페이지 내용 참고해서 직접 해보면서 진행했던 내용의 기록이다.

하나씩 따라가보자.



1. GPG Key 등록하기


$ sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D




2. apt 소스 리스트 추가하기


$ sudo nano /etc/apt/sources.list.d/docker.list


deb https://apt.dockerproject.org/repo ubuntu-precise main


$ sudo apt-get update




3. 이전에 설치한 것이 있다면 지워버리기


$ sudo apt-get purge lxc-docker

$ sudo apt-cache policy docker-engine




4. 필요한 패키지 설치하기 (필자는 이미 설치되어 있던데)


$ sudo apt-get install linux-image-generic-lts-trusty




5. Docker 설치하기


$ sudo apt-get install docker-engine





6. Hello World


$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b901d36b6f2f: Pull complete
0a6ba66e537a: Pull complete
Digest: sha256:8be990ef2aeb16dbcb9271ddfe2610fa6658d13f6dfb8bc72074cc1ca36966a7
Status: Downloaded newer image for hello-world:latest

Hello from Docker.
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker Hub account:
 https://hub.docker.com

For more examples and ideas, visit:
 https://docs.docker.com/userguide/




7. 실행 그룹에 포함되기


    - sudo 없이그냥 실행할 수 있게 되기 위해서는 docker 그룹에 포함이 되면 된다.


$ sudo usermod -aG docker {사용하는 계정}


   - 완전히 로그아웃을 하고 다시 해당 계정으로 로그인을 한 뒤에 터미널을 열면... sudo 없이...


$ docker run hello-world





반응형

 

Docker라는 놈도 Ubuntu 환경에서 그다지 유연하고 편하게 사용할 수 있는 것은 아닌 것 같다.

 

일단, 32bit 환경은 지원하지 않는다. 64bit 환경에서만 Docker를 사용할 수 있다.

또 하나는 12.04 에서는 Docker를 패키지로 바로 제공해주지 않는다.

 

Docker에서는 나름 편하게 설치할 수 있도록 도움은 주고 있지만, 솔직히 좀 귀찮다.

 

 

 

1. Docker 설치

 

$ sudo apt-get install curl

 

$ curl -sSL https://get.docker.com/ | sh

 

$ docker --version
Docker version 1.8.2, build 0a8c2e3

 

 

2. Docker Group 설정

 

사용자 계정으로 docker를 실행할 수 있는지 다음과 같이 확인해보자.

 

$ docker run hello-world
Post http:///var/run/docker.sock/v1.20/containers/create: dial unix /var/run/docker.sock: permission denied.
* Are you trying to connect to a TLS-enabled daemon without TLS?
* Is your docker daemon up and running?

 

위와 같이 나온다면 권한이 없는 것이다. 다음과 같이 그룹 설정을 하자.

 

$ sudo usermod -aG docker <사용자 계정>

 

 

위와 같이 한 뒤에 다시 재로그인을 해야 한다. (심지어 재부팅이 필요할수도)

 

$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world

 

535020c3e8ad: Pull complete
af340544ed62: Pull complete
Digest: sha256:a68868bfe696c00866942e8f5ca39e3e31b79c1e50feaee4ce5e28df2f051d5c
Status: Downloaded newer image for hello-world:latest

 

Hello from Docker.
This message shows that your installation appears to be working correctly.

 

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

 

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

 

Share images, automate workflows, and more with a free Docker Hub account:
 https://hub.docker.com

 

For more examples and ideas, visit:
 https://docs.docker.com/userguide/

 

 

3. Redmine pull

 

$ docker pull sameersbn/postgresql:9.4-4

 

$ docker pull sameersbn/redmine:3.1.1

 

 

 

4. Redmine Run

 

$ docker run --name=postgresql-redmine -d --env='DB_NAME=redmine_production' --env='DB_USER=redmine' --env='DB_PASS=password' --volume=/srv/workspace/redmine/postgresql:/var/lib/postgresql sameersbn/postgresql:9.4-4

 

$ docker run --name=redmine -d --link=postgresql-redmine:postgresql --publish=10083:80 --env='REDMINE_PORT=10083' --volume=/srv/workspace/redmine/redmine:/home/redmine/data sameersbn/redmine:3.1.1

 

 

 

아직은 많은 이해와 활용력이 부족하여 이번 포스팅에서 설명을 달지는 않겠다.

일단 위와 같이 진행을 하면 http://localhost:10083 으로 접속을 하면 Redmine을 만날 수 있다!

 

 

참고 : https://github.com/sameersbn/docker-redmine#installation

 

 

반응형


빌드 환경을 테스트하는데,

Ubuntu 12.04 환경과 Ubuntu 14.04 환경 모두 필요해서 고민하던 중에 문득 떠오른 Docker.


설치까지만 해보고 가지고 놀지를 못하다보니 docker의 개별 image를 어떻게 다루어야 할지,

image와 container를 어떻게 구분을 해야 하는지,

각 container가 어느 정도의 독립성을 갖고 있는지 아무것도 확신이 없다.


하나씩 정복해보도록 하겠다.




1. Image 다운로드 받기


- Ubuntu 이미지를 다운로드 받으려면 다음과 같이 했었다.


$ docker pull ubuntu

latest: Pulling from ubuntu


83e4dde6b9cf: Pull complete 

b670fb0c7ecd: Pull complete 

29460ac93442: Pull complete 

d2a0ecffe6fa: Already exists


$ docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE

ubuntu              latest               d2a0ecffe6fa         2 days ago            188.4 MB

ubuntu              14.04              5ba9dab47459        5 months ago        188.3 MB

ubuntu              14.04.1            5ba9dab47459        5 months ago        188.3 MB

ubuntu              trusty               5ba9dab47459        5 months ago        188.3 MB


- 그런데, 우리가 필요한 12.04 버전이 없다.




2. 특정 버전의 Ubuntu 다운로드 받기


- 우리가 필요한 12.04를 다운로드 받기 위해서는 다음과 같이 하면 된다.


$ docker pull ubuntu:12.04

12.04: Pulling from ubuntu


093e01545ca5: Pull complete 

639d60300768: Pull complete 

50e9f95f98f1: Pull complete 

6d021018145f: Already exists 

ubuntu:12.04: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.


Digest: sha256:ac1fcd76d94daa6ee3e832b540812d42a0095bfdc7c2837e2fc6cee2ec9809d7

Status: Downloaded newer image for ubuntu:12.04



$ docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE

ubuntu              latest               d2a0ecffe6fa          2 days ago           188.4 MB

ubuntu              12.04               6d021018145f        2 days ago           134 MB

ubuntu              14.04               5ba9dab47459       5 months ago        188.3 MB

ubuntu              14.04.1             5ba9dab47459       5 months ago        188.3 MB

ubuntu              trusty               5ba9dab47459        5 months ago        188.3 MB



 

다음 링크 참조하면 도움이 많이 될 것이다.

https://github.com/docker/docker/wiki/Public-docker-images



반응형


예전에 타이젠(Tizen)의 빌드 환경을 통해 어설프게 접하게 된 컨테이너 기반의 가상환경.
최근에 IT 관련 뉴스를 통해서 docker라는 오픈소스 소프트웨어를 알게 되었고 관심을 갖게 되었다.

VMWare, VirtualBox와 같은 Host OS와 분리되어 거의 완벽히 가상의 Destop을 활용하는 것이 장점이 많기는 하지만,
치명적인 약점이 하나 있는데, Host OS에서 프로세스를 실행하는 것과 비교하여 현저히 떨어지는 성능이 이슈이다.

그런데, 이러한 성능 문제를 해결하면서 독립적인 환경을 구축할 수 있도록 도와주는 기술이 있으니,
Linux Container에 기반한 컴패니언(companion) 소프트웨어인 "docker"가 바로 그러한 기술이다!
 

docker 설치 방법은 다음 경로를 통해서 확인할 수 있다.
   - http://docs.docker.com/installation/ubuntulinux



1. 현재 서버 상태 확인
    - docker를 설치하고자 하는 서버의 상태를 먼저 확인하자.

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.1 LTS
Release: 14.04
Codename: trusty

$ uname -a
Linux chani-VBox 3.13.0-39-generic #66-Ubuntu SMP Tue Oct 28 13:30:27 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux



2. docker 설치
   - 패키지로 설치하면 된다.

$ sudo apt-get install docker.io

$ docker -v
Docker version 1.0.1, build 990021a


   - 이걸로 설치는 끝이다.



3. 사용자 설정
   - 별도의 root 권한 (sudo) 없이 그냥 사용하기 위해서 docker 그룹에 포함이 되자.

$ sudo gpasswd -a [현재사용자] docker
사용자 [현재사용자]을(를) docker 그룹에 등록 중

$ sudo service docker.io restart


   - docker 그룹에 포함된 것이 적용되기 위해서는 다시 로그인을 하면 된다.



4. 현재 Image 확인
   - 명령어들을 하나씩 확인해보자.

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE


   - 3번의 설정을 하지 않았으면 위와 같이 명령어를 했을 때, 권한 에러가 난다.
   - 아직은 아무런 이미지가 없는 상태다.



5. 이미지 다운로드 받기
   - docker에서는 미리 이미지를 만들어놓은 것을 제공해준다.
   - 제공해주는 image를 다운로드 받자.

$ docker pull ubuntu
Pulling repository ubuntu
195eb90b5349: Download complete
277eb4304907: Download complete
463ff6be4238: Download complete
c5881f11ded9: Download complete
3db9c44f4520: Download complete
0b310e6bf058: Download complete
5506de2b643b: Download complete
511136ea3c5a: Download complete
6cfa4d1f33fb: Download complete
3af9d794ad07: Download complete
bac448df371d: Download complete
5f18d94c3eca: Download complete
e12c576ad8a1: Download complete
f127542f0b61: Download complete
d497ad3926c8: Download complete
53db23c604fd: Download complete
b7c6da90134e: Download complete
fae16849ebe2: Download complete
dfaad36d8984: Download complete
9f045ea36057: Download complete
47dd6d11a49f: Download complete
0f4aac48388f: Download complete
5796a7edb16b: Download complete
d03a1a9d7555: Download complete
209ea56fda6d: Download complete
30868777f275: Download complete
102eb2a101b8: Download complete
ccb62158e970: Download complete
530dbbae98a0: Download complete
e791be0477f2: Download complete
37dde56c3a42: Download complete
3680052c0f5c: Download complete
8f118367086c: Download complete
22093c35d77b: Download complete


   - 다운로드 받은 것을 확인해 보자.

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
ubuntu              14.10               277eb4304907        3 weeks ago         228.5 MB
ubuntu              utopic              277eb4304907        3 weeks ago         228.5 MB
ubuntu              trusty              5506de2b643b        3 weeks ago         199.3 MB
ubuntu              14.04               5506de2b643b        3 weeks ago         199.3 MB
ubuntu              latest              5506de2b643b        3 weeks ago         199.3 MB
ubuntu              14.04.1             5506de2b643b        3 weeks ago         199.3 MB
ubuntu              12.04               0b310e6bf058        3 weeks ago         126.7 MB
ubuntu              12.04.5             0b310e6bf058        3 weeks ago         126.7 MB
ubuntu              precise             0b310e6bf058        3 weeks ago         126.7 MB
ubuntu              12.10               c5881f11ded9        5 months ago        172.2 MB
ubuntu              quantal             c5881f11ded9        5 months ago        172.2 MB
ubuntu              13.04               463ff6be4238        5 months ago        169.4 MB
ubuntu              raring              463ff6be4238        5 months ago        169.4 MB
ubuntu              13.10               195eb90b5349        5 months ago        184.7 MB
ubuntu              saucy               195eb90b5349        5 months ago        184.7 MB
ubuntu              10.04               3db9c44f4520        6 months ago        183 MB
ubuntu              lucid               3db9c44f4520        6 months ago        183 MB



6. 실행해 보기
   - 다운로드 받은 이미지 중 하나를 실행해보자.

$ cat /etc/issue
Ubuntu 14.04.1 LTS \n \l

$ docker run -i -t ubuntu:12.04 /bin/bash

root@9463f87188ac:/# cat /etc/issue
Ubuntu 12.04.5 LTS \n \l


   - 14.04 버전의 Ubuntu에 docker를 설치하고, 이미지를 다운로드 받은 후
   - 12.04 버전의 Ubuntu를 docker를 통해서 실행을 한 것이다.

   - 마치 telnet이나 ssh를 통해서 접속한 것과 같은 모습이다.


일단 여기에서 한 꼭지 마무리하겠다.

반응형

+ Recent posts