Answers: <p>The proper way to run this image, according to the README, is:</p>
  <pre><code>docker run -d \
      --name basexhttp \
      --publish 1984:1984 \
      --publish 8984:8984 \
      --volume &quot;$HOME/basex/data&quot;:/srv/basex/data \
      --volume &quot;$HOME/basex/repo&quot;:/srv/basex/repo \
      --volume &quot;$HOME/basex/webapp&quot;:/srv/basex/webapp \
      basex/basexhttp:latest
  </code></pre>
  <p>No weird linking to itself is necessary.</p>
  <p>If you wan to run a shell in an already running container (started as above) use:</p>
  <pre><code>docker exec -it basexhttp sh
  </code></pre>
  <p>or you can try bash</p>
  <pre><code>docker exec -it basexhttp bash
  </code></pre>
  <p>but the container is Alpine-based, so bash might not be installed.</p>
  <p>If you want to run a new container and execute shell inside run</p>
  <pre><code>docker run -it --rm basexhttp sh 
  # or bash if it's installed
  docker run -it --rm basexhttp bash
  </code></pre>
  <p>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).</p>
  <p>Edit:</p>
  <p>It seems README is wrong about how to start the container. See my <a href="https://devops.stackexchange.com/questions/12338/cannot-get-bash-prompt-error-response-from-daemon-container-foo-is-not-running">answer</a> to this question for more details.</p>
  
Answers: CC BY-SA 4.0
Answers: 2020-09-04T19:29:48.203Z
Answers: 2020-09-05T12:28:47.377Z
Answers: 2020-09-05T12:28:47.377Z
Answers: Konrad Botor
Answers: <p>Try something along these lines:</p>
  <p><strong>First, create a network for the container:</strong></p>
  <p><code>docker network create -d bridge basexhttpnetwork</code></p>
  <p><strong>Then, run the container in that network:</strong></p>
  <pre><code>docker run -ti --name basexhttp --network=basexhttpnetwork basex/basexhttp:latest basexclient -nbasexhttp
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2020-09-03T16:54:53.437Z
Answers: 2020-09-03T17:02:23.193Z
Answers: 2020-09-03T17:02:23.193Z
Answers: J. Scott Elblein
Answers: <p>After random stumbling, this works:</p>
  <pre><code>root $ 
  root $ docker run -ti -d \
  &gt;     --name basexhttp \
  &gt;     --publish 1984:1984 \
  &gt;     --publish 8984:8984 \
  &gt;     --volume &quot;$(pwd)/basex/data&quot;:/srv/basex/data \
  &gt;     basex/basexhttp:latest
  0cbd60aa6261c7e43646f675765e2dbf38fbfd57f641ca87dc6f6b8cd4fd36e0
  root $ 
  root $ docker exec -ti \
  &gt; --user root \
  &gt; basexhttp \
  &gt; 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 $ 
  </code></pre>
  <p>I'll go through the answers more thoroughly, but thanks to all.</p>
  
Answers: CC BY-SA 4.0
Answers: 2020-09-05T00:47:16.520Z
Answers: 2020-09-05T00:47:16.520Z
Answers: Nicholas Saunders
Body: <p>On the understanding, from <code>#docker</code> on IRC, that the <code>basex</code> container from docker <a href="https://hub.docker.com/r/basex/basexhttp/" rel="nofollow noreferrer">hub</a> died after starting up, how do I now make it run something which doesn't immediately exit?</p>
  <p>I'm only trying to get a <code>bash</code> prompt at this <a href="https://devops.stackexchange.com/q/12338/23443">point</a>:</p>
  <pre><code>docker run -ti     --link basexhttp:basexhttp     basex/basexhttp:latest basexclient -nbasexhttp
  </code></pre>
  <p>results in:</p>
  <pre><code>docker: Error response from daemon: Cannot link to a non running container: /basexhttp AS /charming_villani/basexhttp.
  </code></pre>
  <p>per the <code>basex</code> official <a href="https://docs.basex.org/wiki/Docker" rel="nofollow noreferrer">doc</a>'s.</p>
  <p>In trying to add docker logs I've tried:</p>
  <pre><code>sudo journalctl -fu docker.service
  </code></pre>
  <p>but will have to look into that a bit as there was no output.</p>
  <hr />
  <p>trying a network as suggested:</p>
  <pre><code>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 &quot;/basexhttp&quot; is already in use by container &quot;2473f440e93855f967482aed405c30796a779d3592bd66a00fe48c2131b43a5e&quot;. You have to remove (or rename) that container to be able to reuse that name.
  See 'docker run --help'.
  root $ 
  </code></pre>
  
Comments: CC BY-SA 4.0
Comments: 2020-09-03T16:40:57.423Z
Comments: 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. https://docs.docker.com/network/links/
Comments: J. Scott Elblein
Comments: CC BY-SA 4.0
Comments: 2020-09-03T17:03:20.640Z
Comments: Out of curiosity, how come you're trying to link back to it's own container?
Comments: J. Scott Elblein
Tags: <docker><containers>
Title: how to start a docker container which dies immediately after startup?
UserDisplayName: Nicholas Saunders
ThreadText: # how to start a docker container which dies immediately after startup?
  
  (Asked by: username_0 on 2020-09-03)
  
  On the understanding, from `#docker` on IRC, that the `basex` container from docker [hub](https://hub.docker.com/r/basex/basexhttp/) 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](https://devops.stackexchange.com/q/12338/23443):
  
  ```
  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](https://docs.basex.org/wiki/Docker)'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 $ 
  
  ```
  
  **Tags:** docker, containers
  
  > **Comments:**
  > **username_1**: 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. https://docs.docker.com/network/links/  
  > **username_1**: Out of curiosity, how come you're trying to link back to it's own container?  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_2 on 2020-09-04. Score: 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](https://devops.stackexchange.com/questions/12338/cannot-get-bash-prompt-error-response-from-daemon-container-foo-is-not-running) to this question for more details.
  
  
  ---
  
  ### Answer by username_1 on 2020-09-03. Score: 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
  
  ```
  
  
  ---
  
  ### Answer by username_0 on 2020-09-05. Score: 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.
  
  
  ---
  
  