crops / docker-win-mac-docs

The wiki explains how to use docker containers created to run Yocto Project tools in a Windows or Mac environment.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: failed to start containers: samba

peter197321 opened this issue · comments

I'm trying to create samba container on my windows10 host machine and running the command

`docker start samba`

it gives me an error:

(base) C:\>docker start samba
Error response from daemon: Ports are not available: listen tcp 0.0.0.0:445: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted.
Error: failed to start containers: samba

can you please point me where should I look at to solve this?

Hi @peter197321,

I looked into this a bit today. It seems that when using either Hyper-V or the WSL 2 version of Docker for Windows, it tries to directly listen on the same adapter as the host.(Previous versions evidently bridged instead) This is most likely what is causing the error, because Windows always grabs port 445 for the built-in file sharing.

My guess is that Virtual Box in Docker Toolbox wouldn't have this issue, but that's not an idea solution if you are able to run using Hyper-V or WSL 2.

I'm honestly not sure of the solution. I don't believe Windows Explorer will allow for specifying a different port, which would be the easiest thing. There may indeed be another way to address the issue, but I'm currently unaware of one.

Hello again @peter197321,

I did a bit more research, and if you are using WSL2 it seems there is no longer a need for the volume or for the samba container. While it will require some understanding of WSL2, I'll try to give an example. Ideally this will be added to the docs at some point.

Use explorer.exe to show files within the root filesystem inside WSL2

  1. Setup Docker for Windows using these instructions
    If you already have Docker for Windows installed you can follow the other steps to make sure it is using WSL2.
  2. Start powershell
  3. Start wsl by typing
    wsl
  4. Change to the home directory by typing
    cd
  5. Type the command below, which should open a directory in Windows explorer showing the files in the home directory. This is following the instructions described here.
    explorer.exe .

Now you should something like the following screenshot:
Explorer from WSL2

Setup and use Yocto

Note this is just an example, but should show the general flow.

  1. Change to the home directory in WSL2
    cd
  2. Create a directory for the poky source code and build output
    mkdir workdir
  3. Clone poky into the workdir
    git clone https://git.yoctoproject.org/git/poky workdir/poky
  4. Start crops/poky(after this you will be running from a shell inside the container)
    docker run --rm -it -v `pwd`/workdir:/workdir crops/poky --workdir=/workdir
  5. Source oe-init-build-env
    . ./poky/oe-init-build-env
  6. Use bitbake(in this example we build quilt-native
    bitbake quilt-native
  7. Now you should be able to change to the build directory in explorer to see the output. Example screenshot:
    After build

Disclaimer

Hopefully this is helpful. However, there may be issues with storage space/reclamation on WSL2 based on the comments here. With some investigation, my guess is you will be able to sort them out.

There may even be other issues I'm unaware of considering that I used WSL2 for the first time in order to write this post.

I had a similar issue on macOS and my solution was to map to a different host port (446)
docker create -t -p 446:445 --name samba -v myvolume:/workdir crops/samba

And then connect to smb://localhost:446

Hopefully this works for you as well