Cannot create regular file '/swapfile’ and no in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)


There are two problems with my installation:

[core@marwan discourse]$ sudo ./discourse-setup 
which: no in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)
which: no in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)
WARNING: Discourse requires at least 2GB of swap when running with 2GB of RAM
or less. This system does not appear to have sufficient swap space.

Without sufficient swap space, your site may not work properly, and future
upgrades of Discourse may not complete successfully.

Ctrl+C to exit or wait 5 seconds to have a 2GB swapfile created.
install: cannot create regular file '/swapfile': Operation not permitted
fallocate: cannot open /swapfile: Operation not permitted
mkswap: cannot open /swapfile: No such file or directory
swapon: cannot open /swapfile: No such file or directory
/swapfile       swap    swap    auto      0       0
vm.swappiness = 10
Failed to create swap: are you root? Are you running on real hardware, or a fully virtualized server?
[core@marwan discourse]
  • Docker is installed, but I’m still getting: which: no in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)
  • The discourse-setup script cannot create a swapfile. I tried to do it manually, and I got the same error.

I’m running Fedora CoreOS 32 amd64. I’m pretty sure the second issue is an SELinux issue, but I’m not sure the reason behind the second one. How could I fix them?


1 Like

Standard guide assumes:

  • running as root
  • bare metal or KVM
  • Debian/Ubuntu (so no SELinux by default)

You can either increase the ram size or create a swap file beforehand.


Hi @GalacticLion7

Here is the method in discourse-setup related to checking the docker install:

## Do we have docker?
check_and_install_docker () {
  docker_path=`which || which docker`
  if [ -z $docker_path ]; then
    read  -p "Docker not installed. Enter to install from or Ctrl+C to exit"
    curl | sh
  docker_path=`which || which docker`
  if [ -z $docker_path ]; then
    echo Docker install failed. Quitting.

The first step (for you to troubleshoot your install) is to manually check (confirm) your docker install, by manually running these two commands and posting the results (the command and the results):

which docker

But frankly, discourse-setup has done this for you (but it is good to confirm, of course):

which: no in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)
which: no in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)

In practice, I find your text output in your post a bit odd because, either way, based on the discourse-setup script, you should have got this text from discourse-setup, either:

“Docker not installed. Enter to install from or Ctrl+C to exit”


“Docker install failed. Quitting.”

Because your output appears to not find docker and you are also not getting the text expected from the discourse-setup script, you should, in my view, focus only on insuring you have a solid docker install (not a discourse issue, per se).

So, to summarize, from what you have posted so far, @GalacticLion7, you have a problem with your docker install on SELinux.

As busy discourse team member @Falco mentioned, SELinux is not a supported discourse install; but the good news is that your issue (as posted) is not related to discourse, per se; because per your posted text, your issue is related to docker on SELinux.

Here is a link you might find helpful (2017, but may be relevant):

My suggestion to you @GalacticLion7 , at this point, if you want to run discourse on SELinux (for whatever reason), is to put discourse aside for the time being, and focus on docker on SELinux and perhaps even post in a docker community or forum; and get your docker SELinux install working properly. Then, after you are 100% sure your docker install on SELinux is installed and working property, then you can shift your focus back to your discourse install.

Hope this help you move forward in some small way.



I’m using Fedora CoreOS, which is a container distribution. It ships with Docker, and it works with SELinux. I just want to know where are Discourse’s Docker commands so I can add labels to get it to work with SELinux,

I managed to fix this issue myself by following the CoreOS docs on how to create a Swapfile (Adding swap), and I set SELinux to “permissive” instead of “enforcing” (sudo setenforce 1 && sudo reboot) until the discourse-setup supports SELinux. The other issue is a non-issue.


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.