Is there one?
Because creating a script and disconnecting them one-by-one is quite slow.
Is there one?
I am not sure, but you could ideally start the daemon in offline mode (use the option:
From the docs:
--offline bool - Run offline. Do not connect to the rest of the network but provide local API.
@koalalorenzo my goal is to create a private ipfs network with no external peers, using docker.
if i use
--offline=true param, is it possible to later set it to
true without shutting down the daemon?
ipfs shutdown the docker container shuts down too, so it wont help.
- You’ll need to specify your own bootstrap nodes (see the
ipfs bootstrapcommands). Otherwise, you’ll connect to the rest of the network automatically.
- You may want to turn off local discovery as well: https://github.com/ipfs/go-ipfs/blob/master/docs/config.md#discovery
- You should consider using private networks: https://github.com/ipfs/go-ipfs/blob/master/docs/experimental-features.md#private-networks
Thanks @stebalien for the info.
All these are very promising options but, since i am not very familiar with docker, i am having a hard time to apply them to my docker deployment.
For the “private network” feature to work, i need to put
swarm.key into the ipfs directory. Is there a way for docker not to start the daemon automatically? So i will be able to plant the file into the container and then run the daemon manually.
Also i cannot stop the daemon without shutting down the container.
daemon restart option would be awesome in this situation…
I believe the correct way to do this is to run:
docker run --entrypoint ipfs init
Then, you’d copy in your swarm key. Then, you’d start IPFS normally. However I’m not entirely sure if this’ll work.
@stebalien this produces “executable not found” error.
I managed to do it with:
docker run -di --entrypoint "sh" --name "ipfs" ipfs/go-ipfs
But in docker-compose when i use “sh” as the entrypoint the container exits immediately.
Is it possible to prevent this, in order to
docker exec everything i need?
Can you just get a shell using the
docker run -dti --entrypoint "sh" --name "ipfsXX" ipfs/go-ipfs
docker exec ipfsXX ipfs init
docker exec ipfsXX ipfs bootstrap rm all
docker exec -dti ipfsXX ipfs daemon
For debugging purposes you can have all configs and ids using:
docker exec ipfsXX cat /data/ipfs/config > configfileXX
docker exec ipfsXX ipfs id -f="<id>" > idfileXX
You can directly mount a repository volume, and there you can customise your config file. No need to keep running
docker exec I also strongly suggest to specify the docker tag, as the latest version is not always the stable one.
docker run -v $PWD/ipfs:/data/ipfs -it ipfs/go-ipfs:v0.4.18
Then you can modify the file as you wish and restart the container when you want.
As an alternative you can just run a shell and run the commands from the container:
docker run -v $PWD/ipfs:/data/ipfs -it --entrypoint /bin/sh ipfs/go-ipfs:v0.4.18
Then you can run all the ipfs commands as you did, but without
docker exec ...
I hope it will help
Volumes work like a charm under Linux, but under Windows are pure hell. Lots of errors.
I do the above procedure only once (on deployment) using scripts, so it’s not a problem at all.
The good thing with this implementation is that local dockerized peers auto discover each other, so you have a private network up and running in no time.
PS: Docker has its own feature for configuration files, which works pretty well under Windows too:
Just like the zen of python say: Linux is better than windows.
Give up windows and use Linux or Mac, you will save much time.
Yeah, I also tried in offline mode