Error: I have no name! occurs when trying to run ~$ sudo docker run --volume

Hi
I’m a new user to linux and docker.
My base OS is Linux Ubuntu 18.04.6 LTS.

I have a file that I want to analyse using Docker with various programs.

First I created a Dockerfile using ~$ sudo docker build -t nano_tools_debian
(the # comments are just for me giving myself some notes)

FROM debian

MAINTAINER <naqsdarwin>

RUN apt update && apt upgrade

#----------------------------------------------------------------------

# Below scripts are for initial setup of the container.

# In the case of pip, git, curl etc. remove the # from the install line
# for example if you need to run pip remove the # from <RUN apt-get -y
# install python3-pip>

#----------------------------------------------------------------------


RUN apt-get -y install python3-pip

RUN pip install nanofilt

RUN pip install NanoPlot

RUN pip install NanoPlot --upgrade

RUN apt-get -y install curl

RUN apt-get -y install git

RUN git clone https://github.com/lh3/minimap2

RUN cd minimap2 && make

RUN pip install pycoQC
#https://tleonardi.github.io/pycoQC/installation/

RUN git clone https://github.com/lh3/minimap2

RUN cd minimap2 && make

#----------------------------------------------------------------------

# The above completes the building of the container
# The below is now using the programs to analyse data

#----------------------------------------------------------------------

The command window showed that each RUN task completed successfully.

I’m able to view the docker image using ~$ sudo docker images

I can run the image using ~$ sudo docker run -it nano_tools_debian
the command window shows the below output

computername:~/nextflow/pipelines/docker_training/training_nanotools$ sudo docker run -it nano_tools_debian
root@555a72c61c4c:/# 

I can use the debian bash to look around the file system.

Trying to follow these instructions from Dockerdocs:

START INSTRUCTIONS from Dockerdocs →

Mount volume (-v, --read-only)

$ docker  run  -v `pwd`:`pwd` -w `pwd` -i -t  ubuntu pwd

The -v flag mounts the current working directory into the container. The -w lets the command being executed inside the current working directory, by changing into the directory to the value returned by pwd . So this combination executes the command using the container, but inside the current working directory.

$ docker run -v /doesnt/exist:/foo -w /foo -i -t ubuntu bash

When the host directory of a bind-mounted volume doesn’t exist, Docker will automatically create this directory on the host for you. In the example above, Docker will create the /doesnt/exist folder before starting your container.

← END INSTRUCTIONS from Dockerdocs

I want to mount the dir with the file in it, to the nano_tools_debian image so the image can use the programs above to analyse the file. The results of the analysis from the various programs should be returned to the host OS when the image shuts down.

I’ve used variations of the command below to try and do this

sudo docker run --volume ~/nextflow/pipelines/docker_training/docker_training_b11_slp338_r16:/home/nano_tools_debian_slp338 --workdir ~/nextflow/pipelines/docker_training/docker_training_b11_slp338_r16 -u $(id -u):$(id -g) -it nano_tools_debian

When I do this I get the following error:

computername:~/nextflow/pipelines/docker_training/training_nanotools$ sudo docker run --volume ~/nextflow/pipelines/docker_training/docker_training_b11_slp338_r16:/home/nano_tools_debian_slp338 --workdir ~/nextflow/pipelines/docker_training/docker_training_b11_slp338_r16 -u $(id -u):$(id -g) -it nano_tools_debian
I have no name!@71fd18cac3ff:/home/shaun/nextflow/pipelines/docker_training/docker_training_b11_slp338_r16$ exit
exit

(note I will use the docker images in a nextflow.nf file, but first need to get the images working!)

I’ve been trouble shooting answers to this, from what I can gather, this error relates to user permissions and/or incorrect use of capital letters, spaces, underscores etc.

Out of interest this is the next Dockerfile with the first command that I want to run, I’ve commented out the RUN install commands as these should already be in nano_tools_debian and shouldn’t need to be run every time. But I can’t get to the Run NanoPlot command!

I realise there is a lot going on here, I’d appreciate any help!

FROM debian

MAINTAINER <naqsdarwin>

RUN apt update && apt upgrade

#----------------------------------------------------------------------

# Below scripts are for initial setup of the container.

# In the case of pip, git, curl etc. remove the # from the install line
# for exampl if you need to run pip remove the # from <RUN apt-get -y
# install python3-pip

#----------------------------------------------------------------------


#RUN apt-get -y install python3-pip

#RUN pip install nanofilt

#RUN pip install NanoPlot

#RUN pip install NanoPlot --upgrade

#RUN apt-get -y install curl

#RUN apt-get -y install git

#RUN git clone https://github.com/lh3/minimap2

#RUN cd minimap2 && make

#RUN pip install pycoQC
#https://tleonardi.github.io/pycoQC/installation/

#RUN git clone https://github.com/lh3/minimap2

#RUN cd minimap2 && make

#----------------------------------------------------------------------

# The above completes the building of the container
# The below is now using the programs to anaylse data

#----------------------------------------------------------------------



#--------------------------- -------------------------------------------

# Nanoplot

RUN NanoPlot --threads 16 --tsv_stats --summary ~/nextflow/pipelines/docker_training/docker_training_b11_slp338_R16/sequencing_summary.txt ---plots hex dot --N50 --title SLP338 --outdir ~/nextflow/pipelines/docker_training/docker_training_b11_slp338_R16/docker_nanoplot_output 

#----------------------------------------------------------------------

# NanoFilt

#RUN cd ~/nextflow/pipelines/docker_training/docker_training_B11_SLP338_R16

#RUN gzip -c AIG*.fastq > docker_training.gz

#RUN gunzip -c docker_training.gz | NanoFilt --headcrop 30 --tailcrop 30

#----------------------------------------------------------------------

# Nanoplot again

# Minimap2 

This is not an error. There is no user inside the container having the userid you have on the host. It means you will not have a HOME and a username, but you can execute commands inside the container. It is just the shell prompt complaining about missing username which it supposed to show. If you really want to see a username or to have a home directory you can create a user with the required userid inside the container.

Thanks for that rimelek, so no need to have a username set up in the debian container.

I used the following command

computername:~/nextflow/pipelines/docker_training/docker_training_b11_slp338_r16$ docker run --volume $HOME:$HOME --workdir ${PWD} -u $(id -u):$(id -g) -it nano_tools_debian

which returned

I have no name!@77cfee7fe3d7:/home/name/nextflow/pipelines/docker_training/docker_training_b11_slp338_r16$ ls
AIG357_pass_barcode11_d46709a9_0.fastq	docker_nanoplot_output	sequencing_summary_AIG357_d46709a9.txt

So I know that the pwd that I’m in on my host has mounted correctly into the debian container, and that the container can see the files that need to be analysed. But it will not run the NanoPlot command in the Dockerfile.

I then used

~$ sudo docker rmi nano_tools_debian

to remove the container and start again with

computername:~/nextflow/pipelines/docker_training/docker_training_b11_slp338_r16$ sudo docker build -t nano_tools_debian .

to build the container again.
The container build finished without any errors.

computername:~/nextflow/pipelines/docker_training/docker_training_b11_slp338_r16$ sudo docker image history nano_tools_debian
IMAGE          CREATED          CREATED BY                                      SIZE      COMMENT
54534dcdaf09   25 minutes ago   /bin/sh -c cd minimap2 && make                  5.5MB     
481941094c15   25 minutes ago   /bin/sh -c git clone https://github.com/lh3/…   2.76MB    
e9d8f016d99d   27 minutes ago   /bin/sh -c pip install pycoQC                   82.4MB    
d43d0b163cc2   33 minutes ago   /bin/sh -c apt-get -y install git               44.9MB    
96c1f4cab101   34 minutes ago   /bin/sh -c apt-get -y install curl              3.65MB    
fbcfa2fb50e5   34 minutes ago   /bin/sh -c pip install NanoPlot --upgrade       56.3kB    
4ec7e4709ddf   34 minutes ago   /bin/sh -c pip install NanoPlot                 810MB     
901fedd9c902   48 minutes ago   /bin/sh -c pip install nanofilt                 160MB     
acd0f3339d95   49 minutes ago   /bin/sh -c apt-get -y install python3-pip       378MB     
42da5db31614   55 minutes ago   /bin/sh -c apt update && apt upgrade            17.7MB    
0c1c1ca57df3   56 minutes ago   /bin/sh -c #(nop)  MAINTAINER <naqsdarwin>      0B        
827e5611389a   7 days ago       /bin/sh -c #(nop)  CMD ["bash"]                 0B        
<missing>      7 days ago       /bin/sh -c #(nop) ADD file:5259fc086e8295ddb…   124MB   



I then removed the comment from Run NanoPlot in the dockerfile (below) and used

computername:~/nextflow/pipelines/docker_training/docker_training_b11_slp338_r16$ docker run --volume $HOME:$HOME --workdir ${PWD} -u $(id -u):$(id -g) -it nano_tools_debian

but with the same result as above.

I have no name!@77cfee7fe3d7:/home/name/nextflow/pipelines/docker_training/docker_training_b11_slp338_r16$ ls
AIG357_pass_barcode11_d46709a9_0.fastq	docker_nanoplot_output	sequencing_summary_AIG357_d46709a9.txt

I’m not sure why the files are in the container but the container wont run the NanoPlot command.

Any help would be greatly appreciated.
I’m will also edit the name of this thread if you think the name is not suitable.

FROM debian

MAINTAINER <naqsdarwin>

RUN apt update && apt upgrade

RUN apt-get -y install python3-pip

RUN pip install nanofilt

RUN pip install NanoPlot

RUN pip install NanoPlot --upgrade

RUN apt-get -y install curl

RUN apt-get -y install git

RUN git clone https://github.com/lh3/minimap2

RUN cd minimap2 && make

RUN pip install pycoQC
#https://tleonardi.github.io/pycoQC/installation/

#----------------------------------------------------------------------

# The above completes the building of the container
# The below is now using the programs to anaylse data

#----------------------------------------------------------------------

# Nanoplot

RUN NanoPlot --threads 16 --tsv_stats --summary ~/nextflow/pipelines/docker_training/docker_training_b11_slp338_r116/sequencing_summary.txt ---plots hex dot --N50 --title SLP338 --outdir ~/nextflow/pipelines/docker_training/docker_training_b11_slp338_r16/docker_nanoplot_output/ 

#----------------------------------------------------------------------

# NanoFilt

#RUN cd ~/nextflow/pipelines/docker_training/docker_training_B11_SLP338_R16

#RUN gzip -c AIG*.fastq > docker_training.gz

#RUN gunzip -c docker_training.gz | NanoFilt --headcrop 30 --tailcrop 30

#----------------------------------------------------------------------

Regarding the “I have no name!” username prompt: a container uses an isolated filesystem. It is not aware of any existing users of your host system.

You have two options here:
– To make the container aware of the host’s users, you can use -v /etc/passwd:/etc/passwd:ro to mount it read only into the container (less favored approach, except there are reasons like with the postgres image)
– You create a user while creating the image: add RUN useradd -u {your UID} -g {your GID} -m {whatever username you want to see instead of "I have no username!"} to your Dockerfile. Then set the USER {whatever username you want to see instead of "I have no username!"} instruction in the Dockerfile (after useradd). -u will modify the first user declared in a USER instruction.

This is the command to install, configure and prepare NanoPlot? Looks like the execution of NanoPlot. which is useless at this point because processes started while creating an image will end after the RUN instruction they have been started in. It will NOT be executed when the container is started.

Something seems very wrong with the docker training you are following. Either you skipped steps of the training. Or the trainig lacks steps.

May I suggest this great and free docker training: https://container.training/intro-selfpaced.yml.html

Yes, I was trying to run a bash command in the Dockerfile.
Thanks for the link to the training. I’ll have a read and keep playing and see how I go.

Thanks Meyay, I wasnt able to do the second way of using RUN to create the user, but the first way seem to work, creating root in the container bash.

I am not sure if this means that you try to create the root user, which is not necessary in any image based on a os baseimage, as the root user with UID0, GID0 always exist for them.

The 2nd way is the prefered one though. Can you share your current Dockerfile?

I didn’t intentionally set out to make the root user, though I seem to have fixed this issue just now…

#Dockerfile_debian_only

FROM debian

MAINTAINER <naqsdarwin>


RUN useradd -u 1000 -m bob

USER bob


#RUN apt update && apt upgrade

computername:~/nextflow/pipelines/docker_training/training_nanotools$ sudo docker run -it debian_only bash
bob@eb55d873546a:/$ 

the -g option requires the gid to be existing. Thus, if you want to use a group not existing in the container, you will have to create it before beeing able to assign your user to this groupid with -g

I appreciate you sharing your command

this wasn’t in the instructions that I’ve been following

I know. I kind of imagine that people start to google about the error messages they get and figure it out.

To prevent further surprises, this is the documentation for useradd: useradd(8) — passwd — Debian bullseye — Debian Manpages

Thanks, hopefully it will be just me on this machine, I don’t have any other login on this machine.
If I’m understanding this correctly, once I have an image build and it has all of the programs that I want in it, I then need to use a config file or nextflow.nf file, .yml file to write the commands to mount host OS to the container so that I can write more commands for the programs in the image to analyse the data?
For example, I’d put the nanoplot command in a .nf file?

RUN NanoPlot --threads 16 --tsv_stats --summary ~/nextflow/pipelines/docker_training/docker_training_b11_slp338_R16/sequencing_summary.txt --plots hex dot --N50 --title SLP338 --outdir ~/nextflow/pipelines/docker_training/docker_training_b11_slp338_R16/docker_nanoplot_output

google is also like going down the rabbit hole!

Well, it can be. In this case you should have found plenty of hits about useradd/groupadd.

Nevertheless, please take your time to follow the docker training I did send before. Don’t be intimidated by the number of slides, most of them can be processed in a couple of seconds. Make sure to do all hands-on exercices. This training is a better preparation then most of the instructor led trainings. I participated in two training years ago and both were a joke compared to these slides.

Thanks really appreciate it! Finding courses on this stuff has proved near impossible.