PHP代码无法获得容器信息,php – Docker – 无法从Mac Host访问容器

我似乎无法访问我的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上的容器,对吗?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值