1.创建服务目录和docker 镜像构建文件
mkdir stunserver
touch Dockerfile
vim Dockerfile
写入以下:
FROM ubuntu:latest
EXPOSE 3478/tcp 3478/udp
USER root
RUN set -ex && \
apt-get update && \
apt-get install -y build-essential && \
apt-get install -y libboost-all-dev && \
apt-get install -y libssl-dev && \
apt-get install -y g++ && \
apt-get install -y make && \
apt-get install -y git && \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/*
复制代码
RUN cd /opt && git clone github.com/jselbie/stu… && cd stunserver && make
WORKDIR /opt/stunserver
HEALTHCHECK CMD /opt/stunserver/stunclient localhost
ENTRYPOINT ["/opt/stunserver/stunserver"]
2.构建docker stunserver 镜像
docker image build -t=stun-server .
3.运行docker容器
docker container run -d -p 3478:3478/tcp -p 3478:3478/udp --name=stun-container stun-server