eXist-db / docker-existdb

Docker image builder for eXist-db
GNU Affero General Public License v3.0
11 stars 6 forks source link

please include sh or bash in the image #72

Closed eduarddrenth closed 5 years ago

eduarddrenth commented 5 years ago

since there is no sh or bash I cannot interact with a running container which makes docker development very hard

dizzzz commented 5 years ago

please could you rephrase your ticket more as question or concrete suggestion? It is more like a one-liner now, not stating what you think what should be changed. That would be a start of a clear discussion.

AFAIK the docker image is made as small as possible on purpose; a shell could un-harden the image even?

eduarddrenth commented 5 years ago

For interacting with a container it would be very helpfull to have sh and/or bash available as well as some basic shell commands

eduarddrenth commented 5 years ago

I personally think a minimal shell is a must. For example payara and postgres images also include that.

duncdrum commented 5 years ago

as mentioned in the readme these images are based on distroless images the exclusion of a linux shell is very much by design.

To interact with the running container issue docker exec … commands or use the Java Admin Client to issue shell commands. If you wish to attach your local shell more permanently you can enable the :debug mode of the distroless image here. This step, however, requires you to work with your own base images, as the official images are designed to be used in production as base images, we will not ship with a :debug base images for the reasons that Dannes already mentioned.

grantmacken commented 5 years ago

Most of my shell interaction with the eXist db running in a container, is achieved thru eXist rest api. I mostly use the pattern outlined in following bash script

#!/usr/bin/env bash
IPAddress=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'  exist)
URL="http://${IPAddress}:8080/exist/rest/db"

function post() {
curl  -s \
  -H 'Content-Type: application/xml' \
  -u 'admin:' \
  --data-binary @- "$URL"
}

cat <<EOF | post
<query xmlns='http://exist.sourceforge.net/NS/exist' start='1' max='99' wrap='no'>
<text><![CDATA[
xquery version '3.1';
repo:list() =>
 string-join('&#10;')
]]></text>
</query>
EOF

If you need to interact with the file system on the container, the file module allows you to list move, make directories etc

eduarddrenth commented 5 years ago

ok, the reason for me to ask this is I want to get an image with xar's that are already deployed and indexed. OS access would be very welcome here, for example to start and stop exist.

duncdrum commented 5 years ago

restarting the container will reboot exist, for reindexing you can use either xquery commands via docker exec or you can modify the still image before starting the container.

eduarddrenth commented 5 years ago

I know these options yes, but I want one Dockerfile to prepare a ready to use image

eduarddrenth commented 5 years ago

I guess I'll persist using docker volumes

duncdrum commented 5 years ago

I m confused now, to start and stop exist from within a Dockerfile use multiple FROM, you can prepare indexing operations using RUN as documented in the readme.

If something isn't working please open a new issue with steps to reproduce, as none of these operations seems to depend on the existence or lack of shell.

eduarddrenth commented 5 years ago

I now about those options yes, but find it easier the way I have it now, see: https://bitbucket.org/fryske-akademy/exist-db/src/master/docker/

duncdrum commented 5 years ago

yup looks good, docker-compose is certainly the elegant solution, also recommended in the readme.

docker exec -it <container> "/bin/bash" will never work it should be:

docker exec <container> java -jar start.jar client to talk to exist, or a variation thereof to talk to either jetty or the JVM

line-o commented 2 years ago

to interact with docker instances you can also use node-exist and the cli-tools it exposes.