1

On the understanding, from #docker on IRC, that the basex container from docker hub died after starting up, how do I now make it run something which doesn't immediately exit?

I'm only trying to get a bash prompt at this point:

docker run -ti     --link basexhttp:basexhttp     basex/basexhttp:latest basexclient -nbasexhttp

results in:

docker: Error response from daemon: Cannot link to a non running container: /basexhttp AS /charming_villani/basexhttp.

per the basex official doc's.

In trying to add docker logs I've tried:

sudo journalctl -fu docker.service

but will have to look into that a bit as there was no output.


trying a network as suggested:

root $ 
root $ docker network create -d bridge basexhttpnetwork
74c94db9195cf2b671123d016a9082f4aeacbbcef6ed91e4252744afba45d529
root $ 
root $ docker run -ti --name basexhttp --network=basexhttpnetwork basex/basexhttp:latest basexclient -nbasexhttp
docker: Error response from daemon: Conflict. The container name "/basexhttp" is already in use by container "2473f440e93855f967482aed405c30796a779d3592bd66a00fe48c2131b43a5e". You have to remove (or rename) that container to be able to reuse that name.
See 'docker run --help'.
root $ 
2
  • Just a note, --link is depreciated and it's recommended to just put both containers in a user-defined network so they can communicate with each other. docs.docker.com/network/links Sep 3, 2020 at 16:40
  • Out of curiosity, how come you're trying to link back to it's own container? Sep 3, 2020 at 17:03

4 Answers 4

3

The proper way to run this image, according to the README, is:

docker run -d \
    --name basexhttp \
    --publish 1984:1984 \
    --publish 8984:8984 \
    --volume "$HOME/basex/data":/srv/basex/data \
    --volume "$HOME/basex/repo":/srv/basex/repo \
    --volume "$HOME/basex/webapp":/srv/basex/webapp \
    basex/basexhttp:latest

No weird linking to itself is necessary.

If you wan to run a shell in an already running container (started as above) use:

docker exec -it basexhttp sh

or you can try bash

docker exec -it basexhttp bash

but the container is Alpine-based, so bash might not be installed.

If you want to run a new container and execute shell inside run

docker run -it --rm basexhttp sh 
# or bash if it's installed
docker run -it --rm basexhttp bash

The above will remove the container once you exit bash (but the 3 volumes it creates will remain, you need to find and remove those by yourself).

Edit:

It seems README is wrong about how to start the container. See my answer to this question for more details.

1

Try something along these lines:

First, create a network for the container:

docker network create -d bridge basexhttpnetwork

Then, run the container in that network:

docker run -ti --name basexhttp --network=basexhttpnetwork basex/basexhttp:latest basexclient -nbasexhttp
1

First of all, --link is deprecated.

Secondly, you don't need the daemon logs, instead you need to take a look at what the container's logs are saying

docker logs <container name/id>

Once you have that, you'll need to work your way up in fixing whatever the issue there might be. This isn't docker related.

The first error message states that you're trying to link to a nonexistent container, and the second error pops up because even though the container isn't running (or failed), it's still there, and you can't use the same name for two containers. You need to remove the previous one using docker rm <container name/id>.


how do I now make it run something which doesn't immediately exit?

You do that using the --entrypoint flag, like the following

docker run -ti --entrypoint bash nginx:latest

This won't start the nginx daemon, instead you'll be put into a bash prompt.

Make sure you're using the -ti flag if you want to use something like bash/ash, i.e. an interactive tty.

0

After random stumbling, this works:

root $ 
root $ docker run -ti -d \
>     --name basexhttp \
>     --publish 1984:1984 \
>     --publish 8984:8984 \
>     --volume "$(pwd)/basex/data":/srv/basex/data \
>     basex/basexhttp:latest
0cbd60aa6261c7e43646f675765e2dbf38fbfd57f641ca87dc6f6b8cd4fd36e0
root $ 
root $ docker exec -ti \
> --user root \
> basexhttp \
> bash
bash-4.4# 
bash-4.4# whoami
root
bash-4.4# 
bash-4.4# pwd
/srv
bash-4.4# 
bash-4.4# ls
basex
bash-4.4# 
bash-4.4# exit
exit
root $ 

I'll go through the answers more thoroughly, but thanks to all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.