Skip to content

Run NooBaa in Docker

Guy Margalit edited this page Nov 9, 2020 · 16 revisions

WARNING: THIS IS EXPERIMENTAL ! ! !

Please open issues on bugs, questions or suggestions - thanks.

This is a walkthrough of how to run noobaa containers in docker.

Prepare container images

NOOBAA_CORE_IMAGE=noobaa/noobaa-core:5.4.0
NOOBAA_DB_IMAGE=centos/mongodb-36-centos7

Pulling might take a minute:

docker pull $NOOBAA_CORE_IMAGE
docker pull $NOOBAA_DB_IMAGE

Prepare network

docker network create --driver bridge noobaa-net

Run noobaa-db

docker run --name noobaa-db \
    --net noobaa-net \
    --detach \
    -e MONGODB_ADMIN_PASSWORD=123 \
    -e MONGODB_USER=noobaa \
    -e MONGODB_PASSWORD=123 \
    -e MONGODB_DATABASE=nbcore \
    $NOOBAA_DB_IMAGE

Run noobaa-core

docker run --name noobaa-core \
    --net noobaa-net \
    --detach \
    -p 8080:8080 \
    -p 8443:8443 \
    -p 8444:8444 \
    -p 8445:8445 \
    -p 8446:8446 \
    -p 60100:60100 \
    -e MONGODB_URL=mongodb://noobaa:123@noobaa-db/nbcore \
    -e CONTAINER_PLATFORM=DOCKER \
    -e JWT_SECRET=123 \
    -e SERVER_SECRET=123 \
    -e NOOBAA_ROOT_SECRET=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= \
    -e "AGENT_PROFILE={ \"image\": \"$NOOBAA_CORE_IMAGE\" }" \
    -e DISABLE_DEV_RANDOM_SEED=true \
    -e ENDPOINT_FORKS_NUMBER=1 \
    -e OAUTH_AUTHORIZATION_ENDPOINT= \
    -e OAUTH_TOKEN_ENDPOINT= \
    -e NOOBAA_SERVICE_ACCOUNT= \
    -e CONTAINER_CPU_REQUEST= \
    -e CONTAINER_MEM_REQUEST= \
    -e CONTAINER_CPU_LIMIT= \
    -e CONTAINER_MEM_LIMIT= \
    $NOOBAA_CORE_IMAGE

Create system

Wait for noobaa-core to reply before you send the actual create system request. Use the following accounts_status request to check if the container is responding, and before the system was created it should reply with { "has_accounts": false }:

curl http://127.0.0.1:8080/rpc -sd '{"api": "account_api", "method": "accounts_status" }' | jq .reply

Make sure to run the create system command once, and not to accidentally overwrite the output file (say by re-running from shell history). You can always delete the containers and restart the steps if this gets messed up. Here is the command to create the system:

curl http://127.0.0.1:8080/rpc -sd '{
  "api": "system_api",
  "method": "create_system",
  "params": {
    "name": "noobaa",
    "email": "[email protected]",
    "password": "123"
  }}' > noobaa-create-system-tokens.json

Read the token

NOOBAA_AUTH_TOKEN=$(jq -r .reply.token noobaa-create-system-tokens.json)

Test that it worked

curl http://127.0.0.1:8080/rpc -sd '{
  "api": "system_api",
  "method": "read_system",
  "auth_token": "'$NOOBAA_AUTH_TOKEN'"
  }' | jq .reply.name,.reply.version

Run noobaa-endpoint

docker run --name noobaa-endpoint \
    --net noobaa-net \
    --detach \
    -p 6001:6001 \
    -p 6443:6443 \
    -e CONTAINER_PLATFORM=DOCKER \
    -e DISABLE_DEV_RANDOM_SEED=true \
    -e ENDPOINT_FORKS_NUMBER=1 \
    -e 'MGMT_ADDR=wss://noobaa-core:8443' \
    -e 'MD_ADDR=wss://noobaa-core:8444' \
    -e 'BG_ADDR=wss://noobaa-core:8445' \
    -e 'HOSTED_AGENTS_ADDR=wss://noobaa-core:8446' \
    -e 'MONGODB_URL=mongodb://noobaa:123@noobaa-db/nbcore' \
    -e VIRTUAL_HOSTS= \
    -e REGION=region1 \
    -e ENDPOINT_GROUP_ID=group1 \
    -e LOCAL_MD_SERVER=true \
    -e LOCAL_N2N_AGENT=true \
    -e JWT_SECRET=123 \
    -e NOOBAA_ROOT_SECRET=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= \
    -e NOOBAA_DISABLE_COMPRESSION=false \
    -e "NOOBAA_AUTH_TOKEN=$NOOBAA_AUTH_TOKEN" \
    -e CONTAINER_CPU_REQUEST= \
    -e CONTAINER_MEM_REQUEST= \
    -e CONTAINER_CPU_LIMIT= \
    -e CONTAINER_MEM_LIMIT= \
    $NOOBAA_CORE_IMAGE \
    /noobaa_init_files/noobaa_init.sh init_endpoint

Connect using S3

alias s3="AWS_ACCESS_KEY_ID=123 AWS_SECRET_ACCESS_KEY=abc aws --endpoint-url=http://127.0.0.1:6001 s3"
s3 ls
s3 ls --recursive first.bucket
s3 cp --recursive images/ s3://first.bucket/images/
s3 ls --recursive first.bucket

Open management console

open http://127.0.0.1:8080

Run storage agent on local volume

TODO (let us know if you're interested...)

Stop all containers

docker stop noobaa-endpoint noobaa-core noobaa-db
Clone this wiki locally