spid-sp-test icon indicating copy to clipboard operation
spid-sp-test copied to clipboard

Error in running spid-sp-test as Docker container on Windows 10

Open mic-cyber opened this issue 4 years ago • 5 comments

I was tying to setup a test environment on my host as a Docker container. I started cloning the repo locally. Then, I built the image typing docker build -t italia/spid-sp-test:0.5.6 ., as reported in doc, and the image was successfully built. Then, I tried to run the image in a local container, but this is the output:

$> docker run -it --name idptest-agid-local italia/spid-sp-test:0.5.6 
/usr/bin/env: 'python3\r': No such file or directory

I am working on a Windows 10 host. It seems like something goes wrong when interpeting the CRLF or the EoL chars in general.

mic-cyber avatar Jun 30 '21 16:06 mic-cyber

Seems to be related to this https://askubuntu.com/questions/896860/usr-bin-env-python3-r-no-such-file-or-directory

I have to check on a Windows machine. If you can in the meantime, you should find src/spid_sp_test/spid_sp_test and that shebang at the begin of the file, on top.

Do a eol fix before Building the image, this should do the trick.

If It's the patch feel free to l'et us know, I'll purpose your contribution for the next release

peppelinux avatar Jun 30 '21 22:06 peppelinux

Here It Is https://github.com/italia/spid-sp-test/blob/053c812d34475099697443f94ef3eff94f43c629/src/spid_sp_test/spid_sp_test#L1

peppelinux avatar Jun 30 '21 22:06 peppelinux

For a Quick way, don't rebuild the docker but Just enter in It executing a bash

docker exec -it bash

Then you'll find the spid_sp_test executable and a closer way to test our ipothesys

peppelinux avatar Jun 30 '21 22:06 peppelinux

I resolved this issue disinstalling all Python version installed on my pc, deleting the folders relating to Python that didn't deleted during disinstallation and deleting the related environment variables. Then I installed Python to the path adviced from installer (behind user folder and not in C:\Program Files), than I added python paths on env variable. All works fine.

SeemoneB avatar Mar 01 '22 14:03 SeemoneB

I solved using dos2unix when building the Dockerfile:

FROM python:3.8-slim-buster

LABEL maintainer="Giuseppe De Marco <[email protected]>"

RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        xmlsec1 \
        libxml2-dev \
        libxmlsec1-dev \
        libxmlsec1-openssl \
        dos2unix \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* \
    && adduser \
        --disabled-password \
        --home /spid \
        --quiet \
        spid

COPY . /tmp/src/
RUN pip install --no-cache-dir /tmp/src/ \
    && rm -fr /tmp/src

WORKDIR /spid

RUN dos2unix $(which spid_sp_test)

USER spid

ENTRYPOINT ["spid_sp_test"]
CMD ["--help"]

glatrofa avatar Apr 20 '23 15:04 glatrofa