目的是使用docker容器部署yocto PR服务器。有关PR服务器的更多信息,请访问
   
    following link
   
   :
  
  
   为了尝试这样做,我编写了这个“Dockerfile”来生成docker图像:
  
  FROM ubuntu:16.04
MAINTAINER Yocto <yocto@mydomain.com>
# Update, upgrade and install
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y gawk wget git git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat xterm curl parted python python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping libsdl1.2-dev net-tools
# Set up locales
RUN apt-get -y install locales apt-utils sudo && dpkg-reconfigure locales && locale-gen en_US.UTF-8 && update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
ENV LANG en_US.utf8
# Clean up APT when done
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Replace dash with bash
RUN rm /bin/sh && ln -s bash /bin/sh
# Yocto user management
RUN groupadd -g 1000 yocto && useradd -u 1000 -g 1000 -ms /bin/bash yocto && usermod -a -G sudo yocto && usermod -a -G users yocto
ENV HOME /home/yocto
USER yocto
# Download poky
RUN git clone --branch rocko git://git.yoctoproject.org/poky /home/yocto/poky
# Create some directories
RUN mkdir -p /home/yocto/build /home/yocto/prserv
# Make /home/yocto/poky the working directory
WORKDIR /home/yocto/poky
# Expose listen port
EXPOSE 8585
# Run PR-server
CMD /bin/sh -c " \
    source ./oe-init-build-env ../build \
    && bitbake-prserv --start --file /home/yocto/prserv/sqlite3.db --log /tmp/prserv.log --port 8585 \
"
  
   使用上一个Dockerfile,我构建了一个docker映像:
  
  $ docker build -t docker-prserver .
[...]
Successfully built 362f4599b1b6
Successfully tagged docker-prserver:latest
  
   正如您前面所看到的,该过程成功结束。之后,我运行一个容器:
  
  $ docker run -ti docker-prserver
yocto@b3c9fd06d8af:~/poky$
  
   上一个命令创建了一个shell。我检查进程bitbake prserver是否正在运行:
  
  $ netstat -nat
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State 
  
   如您所见,bitbake prserver进程没有运行(没有侦听端口)。但是,如果我登录到容器并执行CMD命令:
  
  yocto@b3c9fd06d8af:~/poky/build$ source ./oe-init-build-env ../build/ && bitbake-prserv --start --file /home/yocto/prserv/sqlite3.db --log /tmp/prserv.log --port 8585
  
   然后它工作正常:
  
  yocto@b3c9fd06d8af:~$ netstat -nat
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address    State      
tcp        0      0 0.0.0.0:8585            0.0.0.0:*          LISTEN     
  
   它假设在实例化容器时执行CMD,但这并没有发生。编写Dockerfile以运行bitbake prserv服务器侦听公开端口的正确方法是什么?
  
  
   希望你们中的一些人对此有一些经验,并能提供任何有用的反馈。
  
  
   提前非常感谢!:)