Skip to content

Instantly share code, notes, and snippets.

@mapk0y
Last active June 13, 2016 05:53
Show Gist options
  • Save mapk0y/3288ddc0f96a9dc412f3565c4be6abe7 to your computer and use it in GitHub Desktop.
Save mapk0y/3288ddc0f96a9dc412f3565c4be6abe7 to your computer and use it in GitHub Desktop.

イメージの起動

[mapk0y@kona:~/local/docker/docker-fess/10.0](master)$ docker run -d -p 8080:8080 -p 9201:9201 -p 9301:9301 --name fess fess
9171928d7277d65b23b9e0cf9ba6402d7dfc8dbcd8d50720bb4c6a09e16a5046
[mapk0y@kona:~/local/docker/docker-fess/10.0](master)$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                                        
            NAMES
9171928d7277        fess                "/opt/fess/bin/fess /"   6 seconds ago       Up 4 seconds        0.0.0.0:8080->8080/tcp, 0.0.0.0:9201->9201/tcp, 0.0.0.0:9301$
>9301/tcp   fess

ss の結果

yum install iproute で追加

[root@9171928d7277 fess-10.0.3]# ss -4lnp
Netid State      Recv-Q Send-Q                Local Address:Port                               Peer Address:Port              
tcp   LISTEN     0      100                               *:8080                                          *:*                   users:(("java",pid=1,fd=10))
tcp   LISTEN     0      50                        127.0.0.1:9201                                          *:*                   users:(("java",pid=1,fd=288))
tcp   LISTEN     0      50                        127.0.0.1:9301                                          *:*                   users:(("java",pid=1,fd=260))

動作確認

コンテナ内から
[mapk0y@kona:~/local/docker/docker-fess/10.0](master)$ docker exec -t fess curl -I http://localhost:8080/                                                             
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=DBBA29CEBA5BE33498314B5DB247A6DD; Path=/; HttpOnly
Pragma: no-cache
Cache-Control: no-cache, no-store
Expires: Thu, 01 Dec 1994 16:00:00 GMT
Content-Type: text/html;charset=UTF-8
Content-Length: 7719
Date: Mon, 06 Jun 2016 17:10:53 GMT

ホストから(172.17.0.x 経由)

[mapk0y@kona:~/local/docker/docker-fess/10.0](master)$ docker inspect -f '{{ .NetworkSettings.IPAddress }}' fess                                                      
172.17.0.2
[mapk0y@kona:~/local/docker/docker-fess/10.0](master)$ curl -I http://172.17.0.2:8080/                                                                                
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=7D37FFABDB5E7D856483FC5F91C18A73; Path=/; HttpOnly
Pragma: no-cache
Cache-Control: no-cache, no-store
Expires: Thu, 01 Dec 1994 16:00:00 GMT
Content-Type: text/html;charset=UTF-8
Content-Length: 7719
Date: Mon, 06 Jun 2016 17:11:00 GMT

ホストから(127.0.0.1 経由)

[mapk0y@kona:~/local/docker/docker-fess/10.0](master)$ curl -I http://127.0.0.1:8080/                                                                                 
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=3947590EBB2973472C26FC9712EA7524; Path=/; HttpOnly
Pragma: no-cache
Cache-Control: no-cache, no-store
Expires: Thu, 01 Dec 1994 16:00:00 GMT
Content-Type: text/html;charset=UTF-8
Content-Length: 7719
Date: Mon, 06 Jun 2016 17:11:04 GMT

docker-proxy の確認

[mapk0y@kona:~/local/docker/docker-fess/10.0](master)$ sudo ss -4lntp | grep :8080                                                                                    
LISTEN     0      128                       *:8080                     *:*      users:(("exe",pid=28207,fd=6))
[mapk0y@kona:~/local/docker/docker-fess/10.0](master)$ ps aux | grep [2]8207
root     28207  0.0  0.1 177212 23976 ?        Sl   02:00   0:00 docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8080 -container-ip 172.17.0.2 -container-port 8080

fess の docker コンテナ起動時に Network を Host にする場合

以下すべてホストマシン上での作業

[mapk0y@kona:~/local/docker/docker-fess/10.0](master)$ docker run --net=host -d --name fess fess                                                                      
7aea8f9f6797a073997eb8c97b7cb216f2c07fc2fc19444e31a562a984cb0447
[mapk0y@kona:~/local/docker/docker-fess/10.0](master)$ sudo ss -4lnp | grep -e :8080 -e :9[23]01
tcp    LISTEN     0      100                    *:8080                  *:*      users:(("java",pid=30297,fd=10))
tcp    LISTEN     0      50             127.0.0.1:9201                  *:*      users:(("java",pid=30297,fd=288))
tcp    LISTEN     0      50             127.0.0.1:9301                  *:*      users:(("java",pid=30297,fd=260))
[mapk0y@kona:~/local/docker/docker-fess/10.0](master)$ curl -I http://localhost:8080/
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=1AAA1B40A6C77928B77F0610B2D3E115; Path=/; HttpOnly
Pragma: no-cache
Cache-Control: no-cache, no-store
Expires: Thu, 01 Dec 1994 16:00:00 GMT
Content-Type: text/html;charset=UTF-8
Content-Length: 7719
Date: Mon, 06 Jun 2016 17:32:22 GMT

[mapk0y@kona:~/local/docker/docker-fess/10.0](master)$ curl -I http://localhost:9201/
HTTP/1.1 200 OK
Content-Type: text/plain; charset=UTF-8
Content-Length: 0

[mapk0y@kona:~/local/docker/docker-fess/10.0](master)$ curl -I http://localhost:9301/                                                                                 
This is not a HTTP port

注意点:

  • ホストの各ポートが使われるので複数の fess コンテナを起動することは出来ない。
  • ホストのネットワークが利用されるのでパブリッシュ(-p 8080:8080 ...)は必要ない。
  • kibana のコンテナを起動するときも同様に --net=host で起動する必要がある。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment