strangeloop
strangeloop

Reputation: 829

Validating: problems found while running docker build

When I try to build a Docker image using docker build -t audio:1.0.1 ., it builds an image (with an IMAGE ID, but not the name I intended during the build) that automatically runs and stops (but does not get removed) immediately enter image description here

after the build process finishes with the following last lines of output:

enter image description here

The image shows up, without having a TAG or being in a REPOSITORY, when I execute docker images:

enter image description here

How do I troubleshoot this to build a "normal" image?

My Docker version is 18.09.1, and I am using it on macOS Mojave Version 10.14.1

Following is the content of my Dockerfile:

FROM ubuntu:latest

# Run a system update to get it up to speed
# Then install python3 and pip3 as well as redis-server
RUN apt-get update && apt-get install -y python3 python3-pip \
    && pip3 install --trusted-host pypi.python.org jupyter \
    && jupyter nbextension enable --sys-prefix widgetsnbextension

# Create a new system user
RUN useradd -ms /bin/bash audio

# Change to this new user
USER audio

# Set the container working directory to the user home folder
#   WORKDIR /home/jupyter
WORKDIR /home/audio

EXPOSE 8890

# Start the jupyter notebook
ENTRYPOINT ["jupyter", "notebook", "--ip=0.0.0.0", "--port=8890"]

Upvotes: 2

Views: 6751

Answers (1)

codestation
codestation

Reputation: 3498

How do I troubleshoot this to build a "normal" image?

You have the error right there on the screenshot. useradd failed to create the group because it already exists so the docker build was aborted. Note the the audio group is a system one so maybe you don't want to use that.

So either create a user with a different name or pass -g audio to the useradd command to it uses the existing group.

If you need to make the user creation conditional then you can use the getent command to check the user/group existence, for example:

# create the user if doesn't exists
RUN [ ! $(getent passwd audio) ] && echo "useradd -ms /bin/bash audio"

# create the user and use the existing group if it exists
RUN [ ! $(getent group audio) ] && echo "useradd -ms /bin/bash audio -g audio"

Upvotes: 2

Related Questions