如何将Ubuntu映像上的安装保存到Docker Docker代码 问题:

如何将Ubuntu映像上的安装保存到Docker Docker代码 问题:,docker,ubuntu-16.04,Docker,Ubuntu 16.04,我正在尝试将Ubuntu映像导入docker,并安装包括python3、pip3、bs4和PhantomJs在内的多个软件包。然后我想在Docker中将所有这些配置保存为“UbuntuPhantomJS”。因为我现在在Ubuntu镜像上,任何以“docker”命令开头的东西都不起作用。如何保存图像?这是dockerfile: # Import Ubuntu image to Docker FROM ubuntu:16.04 # Install Python3, pip3, library an

我正在尝试将Ubuntu映像导入docker,并安装包括python3、pip3、bs4和PhantomJs在内的多个软件包。然后我想在Docker中将所有这些配置保存为“UbuntuPhantomJS”。因为我现在在Ubuntu镜像上,任何以“docker”命令开头的东西都不起作用。如何保存图像?

这是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的上下文是当前目录。上述dockerfile不是一个标准的dockerfile,并且没有遵循上面提到的所有良好实践。您可以根据需要更改此文件,请阅读文档以获取更多帮助

$ docker build -t ubuntu-phantomjs .