레이블이 Docker인 게시물을 표시합니다. 모든 게시물 표시
레이블이 Docker인 게시물을 표시합니다. 모든 게시물 표시

2018년 7월 22일 일요일

[Automate Build] 2. Set up Jenkins Server on Docker

2. Set up jenkins server on docker
# mkdir -p /share/docker/jenkins
# docker run -d -p 8080:8080 -v /share/docker/jenkins:/var/jenkins_home --name jenkins -u root jenkins
------ update 2018-02-26 ------
** error : I got an error. when I installed jdk 1.7 on Jenkins on the virtualBox SharedFolder(/share/).

# mkdir -p /docker/jenkins
# docker run -d -p 8080:8080 -v /docker/jenkins:/var/jenkins_home --name jenkins -u root jenkins

# docker ps
CONTAINER ID        IMAGE                      COMMAND                  CREATED              STATUS                   PORTS                               NAMES
c78da9c5ae57        jenkins                    "/bin/tini -- /usr/l…"   About a minute ago   Up About a minute        0.0.0.0:8080->8080/tcp, 50000/tcp   jenkins
a95a445b29c8        garethflowers/svn-server   "/usr/bin/svnserve -…"   14 hours ago         Up 4 minutes (healthy)   0.0.0.0:3690->3690/tcp              svn-server

Access jenkins page through browser and you need initial password
# docker exec -it jenkins cat /var/jenkins_home/secrets/initialAdminPassword
a5a62c8d573c4a5682993f0820680349

2-2.Optional
I want jenkins' workspace to be on the virtualBox SharedFolder
Make new virtualBox SharedFolder in setting.


Mount jenkins-workspace
# sudo mount -t vboxsf jenkins_workspace /docker/jenkins/workspace/

2018년 4월 29일 일요일

[Automate Build] 1. Set up SVN Server on Docker

1. Set up SVN Server on Docker
I set up svn server on docker
(SVN server in my company is on the macOS, but it's not matter.)
Install svn server and make repository
# mkdir -p /share/docker/svn-server/svn-root

# docker run --name svn-server \
           --detach \
           --volume /share/docker/svn-server/svn-root:/var/opt/svn \
           --publish 3690:3690 \
           garethflowers/svn-server

# docker ps
CONTAINER ID        IMAGE                      COMMAND                  CREATED             STATUS                           PORTS                    NAMES
a95a445b29c8        garethflowers/svn-server   "/usr/bin/svnserve -…"   3 seconds ago       Up 1 second (health: starting)   0.0.0.0:3690->3690/tcp   svn-server

# docker exec -it svn-server svnadmin create test-repo

# docker exec -it svn-server svnadmin info test-repo
Path: test-repo
UUID: 16f1dd00-4a5d-44f2-adcb-24c03d1b441e
Repository Format: 5
Compatible With Version: 1.9.0
Repository Capability: mergeinfo
Filesystem Type: fsfs
Filesystem Format: 7
FSFS Sharded: yes
FSFS Shard Size: 1000
FSFS Shards Packed: 0/0
FSFS Logical Addressing: yes
Configuration File: test-repo/db/fsfs.conf

Go to container's CLI to set config or add users
# docker exec -it svn-server sh

1-2. Add svn users
# vi /var/opt/svn/test-repo/conf/passwd
### This file is an example password file for svnserve.
...
[users]
# harry = harryssecret
# sally = sallyssecret
seunghyun = 1234567
* Caution : hot key 'shift+Q' doesn't work, use ':' + 'wq'

# vi /var/opt/svn/test-repo/conf/authz
### This file is an example authorization file for svnserve.
...
[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe
default = seunghyun

# [/foo/bar]
# harry = rw
# &joe = r
# * =

[/]
@default = rw

...
* Caution : hot key 'shift+Q' doesn't work, use ':' + 'wq'

# vi /var/opt/svn/test-repo/conf/svnserve.conf
### This file controls the configuration of the svnserve daemon, if you
...
[general]
anon-access = none
auth-access = write
password-db = passwd
authz-db = authz
* Caution : hot key 'shift+Q' doesn't work, use ':' + 'wq'

2018년 2월 17일 토요일

Docker run command simple reference

docker run
Run command create and start container

If you don't have image to make container, Docker automatically search proper image and pull image.

1. you don't have image
# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

# docker run ubuntu
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
1be7f2b886e8: Pull complete 
6fbc4a21b806: Pull complete 
c71a6f8e1378: Pull complete 
4be3072e5a37: Pull complete 
06c6d2f59700: Pull complete 
Digest: sha256:e27e9d7f7f28d67aa9e2d7540bdc2b33254b452ee8e60f388875e5b7d9b2b696
Status: Downloaded newer image for ubuntu:latest

# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
d23a16d47ae7        ubuntu              "/bin/bash"         18 seconds ago      Exited (0) 17 seconds ago                       stoic_johnson

# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              latest              0458a4468cbc        3 weeks ago         112MB

2. you have image
# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              latest              0458a4468cbc        3 weeks ago         112MB

# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

# docker run ubuntu

# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES
6fe3a86ac19a        ubuntu              "/bin/bash"         9 seconds ago       Exited (0) 8 seconds ago                       peaceful_kare

[options]

-it
Using for interactive processes
# docker run -it ubuntu:latest

root@b9f52826da9c:/# ll
total 72
drwxr-xr-x   1 root root 4096 Feb 17 03:58 ./
drwxr-xr-x   1 root root 4096 Feb 17 03:58 ../
-rwxr-xr-x   1 root root    0 Feb 17 03:58 .dockerenv*
drwxr-xr-x   2 root root 4096 Jan 23 22:49 bin/
drwxr-xr-x   2 root root 4096 Apr 12  2016 boot/
drwxr-xr-x   5 root root  360 Feb 17 03:58 dev/
drwxr-xr-x   1 root root 4096 Feb 17 03:58 etc/
drwxr-xr-x   2 root root 4096 Apr 12  2016 home/
drwxr-xr-x   8 root root 4096 Sep 13  2015 lib/
drwxr-xr-x   2 root root 4096 Jan 23 22:49 lib64/
drwxr-xr-x   2 root root 4096 Jan 23 22:49 media/
drwxr-xr-x   2 root root 4096 Jan 23 22:49 mnt/
drwxr-xr-x   2 root root 4096 Jan 23 22:49 opt/
dr-xr-xr-x 118 root root    0 Feb 17 03:58 proc/
drwx------   2 root root 4096 Jan 23 22:49 root/
drwxr-xr-x   1 root root 4096 Jan 23 22:49 run/
drwxr-xr-x   1 root root 4096 Jan 25 18:23 sbin/
drwxr-xr-x   2 root root 4096 Jan 23 22:49 srv/
dr-xr-xr-x  13 root root    0 Feb 17 03:58 sys/
drwxrwxrwt   2 root root 4096 Jan 23 22:49 tmp/
drwxr-xr-x   1 root root 4096 Jan 23 22:49 usr/
drwxr-xr-x   1 root root 4096 Jan 23 22:49 var/

-d
To start a container in detached mode (Running in background)
* Caution : Container will stop when any foreground process don't work in container
I use option '-it' to show running container detached mode on below code
# docker run -it -d ubuntu:latest 
8bb0beb95f0f9f85cbf781650baa2194693c6eb5a425a30bcd5c03b61b1539f3

# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
8bb0beb95f0f        ubuntu:latest       "/bin/bash"         4 seconds ago       Up 4 seconds                            quizzical_goodall

-p
Publish a container᾿s port or a range of ports to the host
docker run -p hostport:containerport
# docker run -d -p 12345:6379 redis
efb01ae0a176e72a1e0c7c1e0b418e1e8d338bf2366c2991af12ad8712c32933

$ telnet localhost 12345
Trying ::1...
Connected to localhost.
Escape character is '^]'.
set test abcde
+OK
get test
$5
abcde
^]
telnet> quit
Connection closed.

--rm
automatically clean up the container and remove the file system when the container exits
seunghyun@ubuntu:~$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
seunghyun@ubuntu:~$ docker run -it ubuntu
root@19c1e015546a:/# exit
exit
seunghyun@ubuntu:~$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES
19c1e015546a        ubuntu              "/bin/bash"         6 seconds ago       Exited (0) 3 seconds ago                       quirky_booth
seunghyun@ubuntu:~$ docker run -it --rm ubuntu
root@28e77f58194b:/# exit
exit
seunghyun@ubuntu:~$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
19c1e015546a        ubuntu              "/bin/bash"         27 seconds ago      Exited (0) 24 seconds ago                       quirky_booth

--name
Defining a name can be a handy way to add meaning to a container
seunghyun@ubuntu:~$ docker run --name seunghyun ubuntu
seunghyun@ubuntu:~$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
seunghyun@ubuntu:~$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES
ee741713119e        ubuntu              "/bin/bash"         5 seconds ago       Exited (0) 4 seconds ago                       seunghyun

reference : https://docs.docker.com/engine/reference/run/

2018년 2월 5일 월요일

Host file copy to container, Container file copy to host

File copy

1. Host to Container
$ docker cp /path/foo.bar containername:/path/foo.bar

2. Container to Host
$ docker cp containername:/path/foo.bar /path/foo.bar