Kimsea Sok
Kimsea Sok

Reputation: 149

How to build docker image that have telnet client

I've been trying to build docker image for my flask app. The application have a script that relied on telnet command. However, after putting the app in then container, the script stop working since the telnet command not found in the container.

How can I make telnet avilable in docker container?

here is my docker file:

# For more information, please refer to https://aka.ms/vscode-docker-python
FROM python:3.8-slim-buster

EXPOSE 5000

# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1

# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1

# Install pip requirements
ADD requirements.txt .
RUN python -m pip install -r requirements.txt

WORKDIR /app
ADD . /app

# Switching to a non-root user, please refer to https://aka.ms/vscode-docker-python-user-rights
RUN useradd appuser && chown -R appuser /app
USER appuser

# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "run:app"]

Upvotes: 2

Views: 13253

Answers (1)

Chris Doyle
Chris Doyle

Reputation: 12189

You can update the package list and install telnet as part of your Docker file. For example.

# For more information, please refer to https://aka.ms/vscode-docker-python
FROM python:3.8-slim-buster

#update package list and install telnet
RUN apt update && apt install telnet

This will refresh the package list of the OS then install telnet into the OS

Upvotes: 4

Related Questions