我似乎无法访问我的Mac上本地运行的简单Docker容器.我可以从容器运行curl localhost并看到默认的Apache页面已经提供,但是我无法从我的机器的浏览器中点击它.
我想知道我是否有VirtualBox配置问题.有没有帮助诊断问题?
Dockerfile
# Build the image of ubuntu 12.04 LTS
from ubuntu:precise
# Run apt-get update
run apt-get -y update
# Install LAMP
run DEBIAN_FRONTEND=noninteractive apt-get -y install lamp-server^
run apt-get -y install vim-tiny curl wget
# Put custom scripts in the container and give proper permissions to them
add ./startup.sh /usr/local/bin/startup.sh
run chmod 755 /usr/local/bin/startup.sh
add site.vhost /etc/apache2/sites-available/site
run a2ensite site
# Expose port 80 to the host machine
expose 80
site.vhost
ServerAdmin webmaster@localhost
DocumentRoot /var/www
Options Indexes FollowSymLinks MultiViews
AllowOverride None
#Order allow,deny allow from all
# Possible values include: debug, info, notice, warn, error, crit, # alert, emerg.
LogLevel warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
startup.sh
#!/bin/bash
a2dissite default
apache2ctl graceful
/usr/bin/mysqld_safe &
开始…
我将使用docker build -t test1构建映像. – 似乎运行正常.
在初始设置时,我运行docker run -d -v $(pwd)/ mysql:/ tmp / mysql test1 / bin / bash -c“cp -rp / var / lib / mysql / * / tmp / mysql”来设置MySQL .
然后我运行docker run -i -t -v $(pwd)/ mysql:/ var / lib / mysql -v $(pwd)/ www:/ var / www -p 8080:80 test1 / bin / bash启动实际的例子.
到达终端后,我运行服务apache2启动,一切似乎运行良好.如果我运行curl localhost,我会得到默认页面.
一切看起来都很棒,它只是从主机上击中它不起作用.我应该可以导航到http://127.0.0.1:8080并将其转发到端口80上的容器,对吗?