- Dockerfile: Template to build docker image
- Docker Image: Can be pushed, pulled, tagged to the docker-registry
- Docker Container: Instance of a tagged docker image
FROM ubuntu:16.04
EXPOSE 8555 9051 40332
USER root
WORKDIR /root
SHELL ["/bin/bash", "-c"]
ENV BTXPWD "xyz"
Example:
cd && \
rm -rf BitCore && \
echo '*** Done 4/10 ***'
SHELL ["/bin/bash", "-c"]
COPY bitcore.conf /tmp
Example:
RUN if [ "$(curl -Is https://bitcore.cc/$BOOTSTRAP | head -n 1 | tr -d '\r\n')" = "HTTP/1.1 200 OK" ] ; then \
wget https://bitcore.cc/$BOOTSTRAP; \
tar -xvzf $BOOTSTRAP; \
rm $BOOTSTRAP; \
fi
Example:
COPY start.sh /root/start.sh
RUN \
rm -f /var/log/access.log && mkfifo -m 0666 /var/log/access.log && \
chmod 755 /root/start.sh /usr/local/bin/*
ENV TERM linux
CMD ["/root/start.sh"]
- no systemd permission within the docker image => run daemon in foreground
- no ufw within the docker image, but configuration on docker host needed
docker build [--build-arg BTXPWD='<bitcore user pwd>'] -t btx-rpc-server .
docker tag btx-rpc-server <repository>/btx-rpc-server
docker login -u <repository> -p"<PWD>"
docker push <repository>/btx-rpc-server
docker rm $(docker ps -a -q)
docker rmi $(docker images -q -f dangling=true)
docker pull <repository>/btx-rpc-server
docker run -p 40332:40332 -p 8555:8555 -p 9051:9051 --name btx-rpc-server -e BTXPWD='NEW_BTX_PWD' -v /home/bitcore:/home/bitcore:rw -d <repository>/btx-rpc-server
docker ps
Please execute "docker run" in 8) before you execute this command:
tail -f /home/bitcore/.bitcore/debug.log
docker ps
docker exec -it btx-rpc-server bash
# you are inside the btx-rpc-server container
root@container# supervisorctl status bitcored
root@container# cat /var/log/supervisor/supervisord.log
# Change to bitcore user
root@container# sudo su bitcore
bitcore@container# cat /home/bitcore/.bitcore/debug.log
bitcore@container# bitcore-cli getinfo
docker run -p 40332:40332 -p 8555:8555 -p 9051:9051 --name btx-rpc-server -e BTXPWD='NEW_BTX_PWD' -v /home/bitcore:/home/bitcore:rw --entrypoint bash <repository>/btx-rpc-server
If the Dockerfile define the VOLUME
you can share files between docker host and docker container.
VOLUME /var/log
To find out the share directory you need the name of the mounted volume:
docker inspect -f "{{json .Mounts}}" btx-rpc-server | jq .
[
{
"Propagation": "",
"RW": true,
"Mode": "",
"Driver": "local",
"Destination": "/var/log",
"Source": "/var/lib/docker/volumes/1092068a8200e64d27a1f5971fba1078980ccd20616119474b59af1557332307/_data",
"Name": "1092068a8200e64d27a1f5971fba1078980ccd20616119474b59af1557332307",
"Type": "volume"
}
]
Here is the mapping:
- DOCKERHOST:
/var/lib/docker/volumes/1092068a8200e64d27a1f5971fba1078980ccd20616119474b59af1557332307/_data
- DOCKER CONTAINER:
/var/log