Skip to content

Commit

Permalink
remove container init documentation from README
Browse files Browse the repository at this point in the history
There is already IPFS Docker documentation where this should live:

https://docs.ipfs.io/how-to/run-ipfs-inside-docker/
  • Loading branch information
guseggert committed Apr 11, 2022
1 parent accf6e2 commit 9935863
Showing 1 changed file with 0 additions and 42 deletions.
42 changes: 0 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,48 +366,6 @@ Basic proof of 'ipfs working' locally:
# QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o
ipfs cat <that hash>

To perform a custom initialization and configuration step, one can mount `.sh` scripts to a `/container-init.d` directory, or mount the entire directory. These scripts are executed if they have `+x` permission, otherwise they are just sourced. Executed scripts can exit with error and abort the initialization process. The scripts may also depend on environment variables set by the `docker run` command or in `docker-compose.yml`. The custom initialization step is **only** performed during IPFS initialization, **after** `ipfs init`, **after** after the swarm key is copied to the IPFS data directory, and **before** the daemon is started. This also enables custom containers to layer extra initialization steps to the base image by adding more scripts to `/container-init.d`.

This example initializes a peer in a private network, without any communication with the default bootstrap nodes because it is performed before the daemon starts:

```bash

# This is the initialization script
TEST_NAME=00-test.sh
TEST_SCRIPT=`pwd`/$TEST_NAME

# The script will add this node when creating the container
PRIV_PEER_IP=127.0.0.1
PRIV_PEER_ID=QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ

# For instructional purposes, create the initialization script here,
# but this may be part of a suite of scripts maintained by the IT team,
# or created inside a custom Dockerfile.
cat >$TEST_SCRIPT <<EOF
echo Removing boostraps...
ipfs bootstrap rm all || exit 1
echo Adding custom boostrap from environment...
MULTIADDR=/ip4/\$PRIV_PEER_IP/tcp/4001/ipfs/\$PRIV_PEER_ID
ipfs bootstrap add \$MULTIADDR || exit 1
exit 0
EOF

# Set the script as executable
chmod +x $TEST_SCRIPT

# Initialize the container with the custom scripted mounted.
# It is also possible to mount the entire /container-init.d
# rather than a single script, if needed
docker run -d --name ipfs_host \
-e PRIV_PEER_IP=$PRIV_PEER_IP \
-e PRIV_PEER_ID=$PRIV_PEER_ID \
-v $TEST_SCRIPT:/container-init.d/$TEST_NAME \
-p 4001:4001 \
-p 127.0.0.1:8080:8080 \
-p 127.0.0.1:5001:5001 \
ipfs/go-ipfs:latest
```

### Troubleshooting

If you have previously installed IPFS before and you are running into problems getting a newer version to work, try deleting (or backing up somewhere else) your IPFS config directory (~/.ipfs by default) and rerunning `ipfs init`. This will reinitialize the config file to its defaults and clear out the local datastore of any bad entries.
Expand Down

0 comments on commit 9935863

Please sign in to comment.