我想知道,如何使用端口转发制作容器?

时间:2017-11-24 06:17:30

标签: docker raspbian raspberry-pi3 access-point hypriot

我在RaspberryPi3上使用Raspbian-Stretch-Light,Hypriot OS,因为在Docker Container上构建了AP。所以我找到了使用raspAP包的Dockerfile。 像这样(它被我修改了一点),

# FROM resin/rpi-raspbian:wheezy
FROM armv7/armhf-ubuntu:yakkety
# FROM hypriot/rpi-node:8.1.3-onbuild

MAINTAINER Gary Ritchie <gary@garyritchie.com>

# RUN apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0x908332071dd2e32e
# RUN echo "deb http://deb.best-hosting.cz/debian/ wheezy main" > /etc/apt/sources.list.d/best-hosting.list

#RUN wget https://archive.raspbian.org/raspbian.public.key -O - | sudo apt-key add -

########
# RUN echo "deb http://archive.raspbian.org/raspbian wheezy main contrib non-free" > /etc/apt/sources.list
# RUN echo "deb-src http://archive.raspbian.org/raspbian wheezy main contrib non-free" >> /etc/apt/sources.list

# RUN echo "deb http://httpredir.debian.org/debian wheezy main" > /etc/apt/sources.list
# RUN echo "deb http://httpredir.debian.org/debian wheezy-updates main" >> /etc/apt/sources.list
# RUN echo "deb http://security.debian.org wheezy/updates main" >> /etc/apt/sources.list

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -q -y install \
        nano \
        sudo \
        net-tools \
        wireless-tools \
        lighttpd \
        php-cgi \
        git \
        && apt-get clean
RUN lighty-enable-mod fastcgi-php
RUN /etc/init.d/lighttpd restart

# AP stuff
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -q -y install \
        wget \
        unzip \
        hostapd \
        bridge-utils \
#       rfkill \
        hostap-utils \
        iw \
        dnsmasq \
        wpasupplicant \
        && apt-get clean
        # wicd-cli \

## Add the following to the end of /etc/sudoers:

RUN echo 'www-data ALL=(ALL) NOPASSWD: ALL\n%www-date ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/www-data

RUN chmod 0440 /etc/sudoers.d/www-data
RUN git clone https://github.com/billz/raspap-webgui /var/www/ap
RUN chown -R www-data:www-data /var/www

EXPOSE 80
EXPOSE 100

ENTRYPOINT ["lighttpd", "-D", "-f", "/etc/lighttpd/lighttpd.conf"]

我使用Makefile进行构建。像这样,

# makefile

raspap: .build
        touch /etc/dnsmasq.conf
## volume-mount all the networking things
        -@docker rm -f $@ > /dev/null
        docker run -d \
                --restart=always \
                --net="host" \
                --privileged \
                --name raspap \
                -p 80:80 \
                -v /etc/network/interfaces:/etc/network/interfaces \
                -v /etc/hosts:/etc/hosts \
                -v /etc/dnsmasq.conf:/etc/dnsmasq.conf \
                -v /etc/wpa_supplicant:/etc/wpa_supplicant \
                -v /etc/hostapd:/etc/hostapd \
                raspap

build: .build

.build: Dockerfile
        docker build --rm=true -t raspap .
        @docker inspect -f '{{.Id}}' raspap > .build

clean:
        docker rm -f raspap

.PHONY: clean

最后,我完成了制作容器,但容器无限重启,没有像这样的端口转发......

结果[#docker ps]

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                            PORTS               NAMES
2b363a63d00d        raspap              "lighttpd -D -f /e..."   12 minutes ago      Restarting (255) 35 seconds ago                       raspap

但是容器端口没有转发,你看。如何使用端口转发创建容器?

0 个答案:

没有答案