Dos2unix available in docker?

I need to convert a text file from dos format to unix. I created the file in Notepad on Windows and copied it into my Docker container and I think there are some windows invisible chars in it that are interfering with a program I want to use. My understanding is that there is a dos2unix utility in Linux but when I open a shell environment in Docker desktop and do:
dos2unix dos-file
it says there is no such command.

Please provide information about where you tried what. And what do you mean by “available in docker”?

Please share the exact commands you used, so we can reproduce what you tried and actually get a chance to understand what you try to achieve and where you try to achieve it :slight_smile:

I’m pretty illiterate when it comes to Linux and Docker, Linux commands, and the different versions of Linux. I use Docker all the time but I’m just starting to understand things like how to execute Linux commands inside a container. So if anything I say below seems to indicate I don’t understand something basic about Docker or Linux please feel free to correct me. I’ve got this to work in Ubuntu now so even though it’s a bit of a pain: I have to load the file into Ubuntu, run dos2unix and then save it and then reload it into Docker, at least it works.

So here’s the detail: This is for a configuration file for a demo that shows how to integrate AllegroGraph with ChatGPT. I’m using the AllegroGraph Docker container from the Docker hub. You have to create .def files like historicalFigures.def that are very simple. They just point to things like your Open AI key, the AllegroGraph repository you want to generate embeddings for, and a few other things. Then (inside Docker, so I’ve been using the “Open in Terminal” option) you run a tool called agload. When I was running agload with the historicalFigures.def file that I created in Notepad++ in Windows I was getting errors that the people at Franz said seemed to be because agload is expecting a file formatted for Unix/Linux not Windows. So just as I run agload at the terminal inside Docker desktop, I would like to be able to just run dos2unix on those “.def” files

I tried the procedure described here: apt - How to install dos2unix on a Ubuntu app on a Windows-10 machine - Ask Ubuntu which works on Ubuntu on Windows (WSL) but in the Docker container when I enter: “sudo add-apt-repository universe” it says “sudo: add-apt-repository: command not found”.

Notepad++ provides a feature to switch from Windows to Unix file endings. Wouldn’t it be easier to just use that feature?

When it comes to running commands in a container: of course they need to exist. Usually images include the bare minimum dependency to run the main application. If you need additional tools, you need to install them.

Btw. it would have been less ambiguous, if you just shared the exact commands and their output, like this (of course using the complete commands, and not with the three dots like I did as example)

docker run ... 
dos2unix ...

This would have allowed us to respond to your exact situation, rather trying to describe things in prose.


Notepad++ provides a feature to switch from Windows to Unix file endings. Wouldn’t it be easier to just use that feature?

Yes, that would definitely be easier! I didn’t realize that was a feature. It seems I can do that by changing Edit>EOL Conversion from Windows to Unix is that correct? Do I need to change anything else such as encoding (currently set to UTF-8)?

Sounds about right. UTF-8 is just fine.

1 Like