Do i open a terminal inside of docker or do I use external terminal to install this?

Hi I want to open a terminal to permanently add Espeak, with I believe is this command to add it from within Alpine?

apk add espeak

or do i run an external terminal and use the command

docker run -it espeak-ng/espeak-ng

As you can see I am confused as to how to achieve this :upside_down_face:

Thanks

I’m not sure what you call external terminal. Your first comand uses the apk package manager. I assume you raun it in a container. The second just runs a new container from an image which possibly gives you the temrinal in which you can run the previous command. So both are the same.

If you want to do it properly, create a Dockerfile, build your own image, push it to a registry or just use it locally and run the container from that image, so you don’t have to install anything interactively in a container. It is not just that you don’t have to, it is something thaty ou always have to avoid.

To learn about creating Docke rimages, I can recommend some links

Recommended links to learn the basics and concepts:

The last link is (currently) about Docker Desktop which is Docker CE in a virtual machine whith a GUI.

Hi,

I am absolute beginner so at the moment I would rather not create a dockerfile.

So far I have installed Node-RED & Grafana & PostgreSQL via compose.yaml file.

I cannot find a terminal inside of Alpine linux docker ?
The external terminal I mentioned, is the PC I installed Docker onto.

Sorry if my technical terms are not correct :thinking:

Thanks

I think I have installed it … i used

docker exec -it --user root gb-node-red-1 sh

then added

apk add espeak

Then i tried espeak “hello, world”

and then in the terminal i got line and lines and like this …

ALSA lib confmisc.c:855:(parse_card) cannot find card ‘0’
ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name
ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM sysdefault
ALSA lib confmisc.c:855:(parse_card) cannot find card ‘0’

What you need to understand, as a beginner, is that you don’t install software into a container. A container is not a virtual machine, Do not treat it like one. You install software into an Image, and then create the container from that image. This is because when the container exits, all the software you installed is gone because containers are ephemeral. This is why you want to learn how to use a Dockerfile to create an image and then create a container from that image with all of the software already installed.

Here is an example of a Dockerfile that you might use given what you told us you are trying to do:

FROM alpine:latest
RUN apk add espeak

You can build the image with this command:

docker build -t espeak .

You can then run a shell in a container created from this image with:

docker run --rm -it --name espeak --privileged=true --device=/dev/snd:/dev/snd espeak sh

Notice that I added --privileged=true to allow the container to access the host machine and --device=/dev/snd:/dev/snd to bind the sound device of the host computer to the container because you are using espeak which requires a sound card.

Unfortunately, this still gives the same error that you are encountering. I’ve followed several examples that I’ve found on the internet and none of them seem to work. One used ALSA but the speaker-test threw the same error that you are getting with espeak.

I did come across some solutions that used PulseAudio as a driver installed on your host computer, but I didn’t test them out. I would say that as a beginner, you are in way over your head. Trying to get sound to work from a Docker container is not trivial. But don’t give up. You will undoubtedly learn a lot about Docker along the way. I would search for “docker audio device” and try a few things out. Good Luck.

3 Likes

From another topic we know the user uses Docker Desktop of Windows.
Thus, “the host” in his case is the utility vm of Docker Desktop.

Hi rofrano,

Thanks for all that info, very helpful, for the time being I have stopped trying to use espeak.
I have found that I can use Alexa to announce using Node-RED & a Alexa node.
All of this is in my Docker desktop install and working well. :slightly_smiling_face:

Thanks :+1:

You’re welcome! I’m glad you found a solution. :slightly_smiling_face: