如何我在Ubuntu镜像安装保存到码头工人
问题描述:
泊坞代码
# Import Ubuntu image to Docker
docker pull ubuntu:16.04
docker run -it ubuntu:16.04
# Instsall Python3 and pip3
apt-get update
apt-get install -y python3 python3-pip
# Install Selenium
pip3 install selenium
# Install BeautifulSoup4
pip3 install beautifulsoup4
# Install library for PhantomJS
apt-get install -y wget libfontconfig
# Downloading and installing binary
mkdir -p /home/root/src && cd &_
tar jxvf phantomjs-2.1.1-linux-x86_64.tar.bz2
cd phantomjs-2.1.1-linux-x86_64/bin/
cp phantomjs /usr/local/bin/
# Installing font
apt-get install -y fonts-nanum*
问题
我试图导入Ubuntu的形象泊坞窗并安装serveral的包inscluding python3,PIP3,BS4和PhantomJs。然后我想将所有这些配置保存在Docker中作为“ubuntu-phantomjs”。由于我目前在Ubuntu映像上,任何以“docker”命令开头的内容都不起作用。我怎样才能保存我的图像?如何我在Ubuntu镜像安装保存到码头工人
答
这里是dockerfile:
# Import Ubuntu image to Docker
FROM ubuntu:16.04
# Install Python3, pip3, library and fonts
RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
wget libfontconfig \
fonts-nanum*
&& rm -rf /var/lib/apt/lists/*
RUN pip3 install selenium beautifulsoup4
# Downloading and installing binary
RUN mkdir -p /home/root/src && cd &_ tar jxvf phantomjs-2.1.1-linux-x86_64.tar.bz2 && cd phantomjs-2.1.1-linux-x86_64/bin/ && cp phantomjs /usr/local/bin/
现在保存在名为dockerfile
文件中的代码,在同一个目录中,其中文件被存储在一个打开一个终端,并运行以下命令后:
$ docker build -t ubuntu-phantomjs .
-t
表示目标是ubuntu-phantomjs
而.
表示docker的上下文是当前目录。上述码头文件不是标准文件,并且不遵循here提及的所有良好实践。您可以根据需要更改此文件,阅读文档以获得更多帮助。