如何在nercore的docker使用ping/telnet/vi等基础命令

2020-01-16 17:34发布

问题:

我的虚拟机是centos7,我现在发布了一个netcore的镜像,但是内部无法使用linux的一些基本命令。我该如何使用呢。如下是我的dockfile

See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
RUN yum -y install telnet bin/bash
RUN yum -y install ping bin/bash
RUN yum -y install vim bin/bash

COPY . .

ENTRYPOINT ["dotnet", "Tourism.Api.dll"]
我试图写
RUN yum -y install telnet bin/bash
RUN yum -y install ping bin/bash
RUN yum -y install vim bin/bash
这样的命令,但是结果是
/bin/sh: 1: yum: not found
The command '/bin/sh -c yum -y install telnet bin/bash' returned a non-zero code: 127
类似这样的失败提示,所以我不知道该如何解决

回答1:

aspnet:3.1-buster-slim 镜像用的系统是 Debian ,需要用 apt-get 安装。

apt-get update
apt install install telnet
apt-get install iputils-ping
apt-get install vim