你在树莓派上运行的容器,应该在FROM行中放入什么?

huangapple go评论60阅读模式
英文:

For a container running on Raspberry Pi what should I put in the FROM line?

问题

> 构建Docker容器时,每次尝试构建时都出现以下错误:

> 守护程序的错误响应:当前上下文中没有构建阶段

以下是我的Dockerfile外观:

RUN apt-get update && \
   apt-get -y install openvpn && \
   type -p resolvconf >/dev/null || apt-get -y install resolvconf
    
 CMD ["openvpn", "--config", "openvpnconfig.ovpn", "--script-security", "2", "--up", "/etc/openvpn/update-resolv-conf", "--down", "/etc/openvpn/update-resolv-conf"]

我看到了这个答案,它说我需要在顶部添加一个FROM行。

我看到一些示例,其中包括诸如FROM ubuntu:14.04FROM ubuntu:latest或另一个现有的镜像。<br>
由于我不是从现有镜像中拉取,那我应该放什么呢?我在树莓派上运行,所以不使用Ubuntu。

英文:

I am building a Docker container and each time I try to build it, I get this error:

> Error response from daemon: no build stage in current context

Here's what my Dockerfile looks like:

RUN apt-get update &amp;&amp; \
   apt-get -y install openvpn &amp;&amp; \
   type -p resolvconf &gt;/dev/null || apt-get -y install resolvconf
    
 CMD [&quot;openvpn&quot;, &quot;--config&quot;, &quot;openvpnconfig.ovpn&quot;, &quot;--script-security&quot;, &quot;2&quot;, &quot;--up&quot;, &quot;/etc/openvpn/update-resolv-conf&quot;, &quot;--down&quot;, &quot;/etc/openvpn/update-resolv-conf&quot;]

I saw this answer, which says I need a FROM line at the top.

Some examples I have seen say stuff like FROM ubuntu:14.04 or FROM ubuntu:latest or another existing image.<br>
Since I am not pulling from an existing image, what would I put there? I'm running it on a Raspberry Pi, so not using Ubuntu.

答案1

得分: 1

使用树莓派命令行,您可以尝试以下命令:

cat /proc/cpuinfo | grep model

这应该返回树莓派中使用的CPU型号,类似于 model name: ARMv7 Processor rev 4 (v7l)

现在使用 Variant,运行 cat /etc/os-release 命令,可能会返回“jessie”或“wheezy”变种。

这里您关心的输出是:

...
PRETTY_NAME=&quot;Raspbian GNU/Linux 8 (jessie)&quot;
...
VERSION=&quot;8 (jessie)&quot;
...

现在您可以在 dockerhub 上查找 ARMv7 或您正在使用的版本。根据您的需求,您可以选择从您的变种中拉取镜像 FROM

例如,如果您正在使用 ARMv7,需要 python2.7,并且您的变种是 jessie,您可以将以下 FROM 添加到您的 Dockerfile 的顶部:

FROM arm32v7/python:2.7.13-jessie
英文:

With your Pi Command line you can try this command

cat /proc/cpuinfo | grep model

This should return the model of the CPU used in pi, something like model name: ARMv7 Processor rev 4 (v7l)

Now with Variant, cat /etc/os-release ,you may have “jessie” or “wheezy” variants

The output you care about here is

...
PRETTY_NAME=&quot;Raspbian GNU/Linux 8 (jessie)&quot;
...
VERSION=&quot;8 (jessie)&quot;
...

Now you can look at dockerhub for the ARMv7 or whatever you have it. And according to your need, you can select what you pull image FROM according to your variant

For example, If you are using ARMv7 and you need python2.7 and jessie is your variant, You can add this FROM to the top of your Dockerfile

FROM arm32v7/python:2.7.13-jessie

huangapple
  • 本文由 发表于 2023年3月12日 14:53:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/75711508.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定