简体   繁体   中英

cpplint misbehaving in docker container

I'm trying to run cpplint.py inside a Docker container.

Here's the Dockerfile which I use to make an image lint:latest:

FROM ubuntu:18.04

# update and install dependencies
RUN apt-get update \
    && apt-get -y -qq install software-properties-common \
    && apt-get -y -qq install python3.7 \
    && ln -s /usr/bin/python3 /usr/bin/python

# install our linter
COPY cpplint.py /usr/sbin
RUN chmod +x /usr/sbin/cpplint.py

# install a test file
COPY Types.h .

I run the container like this:

$ docker run -it --rm lint:latest bash
root@17a20248ee33:/# cpplint.py Types.h
root@17a20248ee33:/# echo $?
1

Which shows cpplint.py returning an error code.

Note that running cpplint.py --help displays the help screen as normal. It's long so I'm not going to list it here.

Running the same command outside of a container works fine:

$ ./cpplint.py Types.h
Types.h:0:  No #ifndef header guard found, suggested CPP variable is: _LINT_TYPES_H_  [build/header_guard] [5]
Done processing Types.h
Total errors found: 1

According to Docker's run reference both STDOUT and STDERR are attached to the terminal by default. I understand that cpplint writes errors to STDERR, but don't think that's why I don't see the same output when run within a container. I've tried the 2>&1 manoeuvre to force STDERR onto STDOUT and got the same results.

Any ideas why I don't see output from cpplint.py when I run it in a container?

In the container try installing cpplint.py using pip3

FROM ubuntu:18.04

# update and install dependencies
RUN apt-get update \
    && apt-get -y -qq install software-properties-common \
    && apt-get -y -qq install python3.7 python3-pip \
    && pip3 install cpplint

# install a test file
COPY Types.h .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM