Bug 1757168 - /bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8) when running fedora container
Summary: /bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8) when ...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: singularity
Version: 30
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Dave Dykstra
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-09-30 18:01 UTC by Jun Aruga
Modified: 2019-10-01 11:49 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-10-01 11:49:33 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Jun Aruga 2019-09-30 18:01:33 UTC
Description of problem:

When running fedora container by singularity, the warning "/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)" is outputted.
This does not happen for docker (docker-ce) and podman.

Version-Release number of selected component (if applicable):
$ rpm -q singularity
singularity-3.4.0-1.2.fc30.x86_64

(Latest version on Fedora 30)

How reproducible:

Steps to Reproduce:
1. $ singularity run docker://fedora echo "fedora"


Actual results:
$ singularity run docker://fedora echo "fedora"
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
fedora


Expected results:
The warning is not outputted.


Additional info:

My local host environment

Fedora 30

```
$ env | grep LC_ALL
LC_ALL=en_US.UTF-8

$ rpm -q glibc-langpack-en
glibc-langpack-en-2.29-22.fc30.x86_64
```

It only happens for fedora container.

```
$ singularity run docker://ubuntu echo "ubuntu"
ubuntu

$ singularity run docker://fedora echo "fedora"
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
fedora

$ singularity run docker://alpine echo "alpine"
alpine
```

This warning does not happen for docker (docker-ce) and podman.
I suppose that singularity has a unique logic for the locale comparing from docker and podman.

```
$ singularity run docker://fedora echo "fedora"
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
fedora
```

```
$ rpm -qf /usr/bin/docker
moby-engine-18.06.3-2.ce.gitd7080c1.fc30.x86_64

$ docker run fedora echo "fedora"
fedora
```

```
$ rpm -q podman
podman-1.5.1-3.fc30.x86_64

$ podman run fedora echo "fedora"
fedora
```

Comment 1 Dave Dykstra 2019-09-30 20:59:24 UTC
I can reproduce the issue on el7 with the latest singularity in epel-testing and the following command

$ rpm -q singularity
singularity-3.4.1-1.1.el7.x86_64
$ LC_ALL=en_US.UTF-8 singularity run docker://fedora echo "fedora"
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
fedora

The reason is that unlike docker and presumably podman, by default singularity imports all environment variables.  You can work around it by using the run --cleanenv or -e option.   In addition apparently the fedora container does not by default support the en_US.UTF-8 locale.

I can also reproduce by explicitly setting LC_ALL in docker:
$ docker run fedora bash -c 'LC_ALL=en_US.UTF-8 echo fedora'
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8): No such file or directory
fedora

Is that a sufficient answer for you?

Comment 2 Jun Aruga 2019-10-01 11:49:33 UTC
Hi Dave. Yes, it's a sufficient answer! Thank you for checking it!

I was able to suppress the warning with "--cleanenv" option.

```
$ singularity run --cleanenv docker://fedora echo "fedora"
fedora
```

I was able to reproduce below warning too.

```
$ docker run fedora bash -c 'LC_ALL=en_US.UTF-8 echo fedora'
fedora
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8): No such file or directory
```

I would close this ticket.
Thanks, again.


Note You need to log in before you can comment on or make changes to this bug.