Dockerのコンテナにホスト上のブラウザから接続できない
Dockerのコンテナのポートにホストのブラウザから接続するにはどうすればいいのでしょうか?
下のDockerfile, docker-compose.ymlで1344番のポートにホストから接続できるようにしているのですが、ホスト側のブラウザでlocalhost:1344
にアクセスしてもサーバへの接続を確立できない
となってしまいます
port 1344ではbottle(pythonのwaf)のアプリケーションを動かしています
使っているDockerのversion: Docker 1.12.0-rc4-beta19
OS: OS X 10.11.6
Dockerfile:
from ubuntu:latest
maintainer myname
run mkdir ~/app
copy vim /root/.vim
copy vimrc /root/.vimrc
#update
run apt-get update
run apt-get -y update
run apt-get -y install libssl-dev
run apt-get -yf install curl
run apt-get -y install clang
run apt-get -y install lldb
run apt-get -y install make
run apt-get -y install libsqlite3-dev
run apt-get -y install man
run apt-get -y install vim
run apt-get -y install git
run apt-get -y install pkg-config
run apt-get -y install zip
run apt-get -y install unzip
run apt-get -y install language-pack-ja-base
run apt-get -y install language-pack-ja
run apt-get -y install language-pack-en-base
run apt-get -y install language-pack-en
run apt-get -y install fcitx-mozc
run apt-get -y install libreadline-dev
# setting locale to japanese
run update-locale LANG=ja_JP.UTF-8 LANGUAGE=ja_JP:ja
env LANG ja_JP.UTF-8
env LC_CTYPE ja_JP.UTF-8
env LC_MESSAGES en_US.UTF-8
run im-config -n fcitx
# end of locale settings
#install postgresql
run apt-get install postgresql
run apt-get install libpq-dev
run apt-get install postgresql-plpython3-9.5
# install latest python3 and some python packages (https://github.com/docker-library/python/blob/3db904b3f5407840e591daf3aa54670a685b22b3/3.5/Dockerfile)
ENV GPG_KEY 97FC712E4C024BBEA48A61ED3A5CA953F73C700D
ENV PYTHON_VERSION 3.5.2
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
ENV PYTHON_PIP_VERSION 8.1.2
RUN set -ex \
&& curl -fSL "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" -o python.tar.xz \
&& curl -fSL "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" -o python.tar.xz.asc \
&& export GNUPGHOME="$(mktemp -d)" \
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEY" \
&& gpg --batch --verify python.tar.xz.asc python.tar.xz \
&& rm -r "$GNUPGHOME" python.tar.xz.asc \
&& mkdir -p /usr/src/python \
&& tar -xJC /usr/src/python --strip-components=1 -f python.tar.xz \
&& rm python.tar.xz \
\
&& cd /usr/src/python \
&& ./configure \
--enable-loadable-sqlite-extensions \
--enable-shared \
&& make -j$(nproc) \
&& make install \
&& ldconfig \
&& pip3 install --no-cache-dir --upgrade pip==$PYTHON_PIP_VERSION \
&& [ "$(pip list | awk -F '[ ()]+' '$1 == "pip" { print $2; exit }')" = "$PYTHON_PIP_VERSION" ] \
&& find /usr/local -depth \
\( \
\( -type d -a -name test -o -name tests \) \
-o \
\( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
\) -exec rm -rf '{}' + \
&& rm -rf /usr/src/python ~/.cache
# make some useful symlinks that are expected to exist
RUN cd /usr/local/bin \
&& ln -s easy_install-3.5 easy_install \
&& ln -s idle3 idle \
&& ln -s pydoc3 pydoc \
&& ln -s python3 python \
&& ln -s python3-config python-config
#install some packages
run pip --no-cache-dir install bottle
run pip --no-cache-dir install feedparser
run pip --no-cache-dir install psycopg2
run pip --no-cache-dir install -U pip
run pip --no-cache-dir install -U setuptools
# end of latest python installation
#prompt and compiler environment variables
env CC clang
env CXX clang++
run echo 'export PS1="\h:\W \u$ "' >> ~/.bashrc
# git config
run git config --global user.name "myname"
run git config --global user.email "my@email.address"
run git config --global color.ui true
run git config --global core.editor vim
expose 1000
expose 2000
expose 3000
expose 4000
expose 5000
expose 1344
docker-compose.yml:
version: '2'
services:
datastore:
image: busybox:latest
volumes:
- ./share:/share_to_container
### base (ubuntu)
base:
build: ./
ports:
- "1344:1344"
- "8000:8000"
volumes:
- ./app:/app
volumes_from:
- datastore
links:
- db
- webserver
db:
build:
context: .
dockerfile: "mysqlfile"
environment:
- MYSQL_ROOT_PASSWORD=hello
ports:
- "3306:3306"
volumes:
- ./mysql:/mysql
volumes_from:
- datastore
webserver:
image: nginx
ports:
- "8080:80"
volumes:
- ./nginx/mysite.template:/etc/nginx/conf.d/mysite.template
volumes_from:
- datastore