vault with docker

doker-compose.yml file

version: '3'
services:
    vault:
        image: vault
        container_name: vault
        ports:
          - 8200:8200
        volumes:
          - ./data:/vault/data:rw
          - ./config:/vault/config:rw
        cap_add:
          - IPC_LOCK
        entrypoint: vault server -config=/vault/config/vault.conf

vault.conf

ui = true

storage "file" {
  path = "/vault/data"
}

listener "tcp" {
  address     = "0.0.0.0:8200"
  tls_disable = 1
  #tls_disable = 0
  #tls_cert_file = "/vault/conf/cert/fullchain.pem"
  #tls_key_file = "/vault/conf/cert/privkey.pem"
}

vault client in java

package com.crossinx;

import java.util.List;
import java.util.Map;

import com.bettercloud.vault.Vault;
import com.bettercloud.vault.VaultConfig;
import com.bettercloud.vault.VaultException;
import com.bettercloud.vault.api.Auth.TokenRequest;
import com.bettercloud.vault.response.AuthResponse;
import com.bettercloud.vault.response.LogicalResponse;

public class VaultService {

    private int vaultEngineVersion = 2;
    private String vaultAddress;
    private String vaultToken;
    private String defaultTtl = "1h";

    public void setVaultAddress(String vaultAddress) {
        this.vaultAddress = vaultAddress;
    }

    public void setVaultToken(String vaultToken) {
        this.vaultToken = vaultToken;
    }

    private Vault getDefaultConfig() throws VaultException {
        VaultConfig config = new VaultConfig()
                .engineVersion(vaultEngineVersion)
                .address(vaultAddress)
                .token(vaultToken)
                .build();
        return new Vault(config);
    }

    public String getSecretValue(String path, String key) {
        String value = null;
        try {
            value = getDefaultConfig()
                    .logical()
                    .read(path)
                    .getData()
                    .get(key);
        } catch (VaultException e) {
            e.printStackTrace();
        }
        return value;
    }

    public LogicalResponse setSecretValue(String path, Map secrets) {
        try {
            return getDefaultConfig()
                    .logical()
                    .write(path, secrets);
        } catch (VaultException e) {
            e.printStackTrace();
        }

        return null;
    }

    public String createToken() {
        return createToken(defaultTtl, null);
    }

    public String createToken(String ttl, List polices) {
        try {
            TokenRequest tokenRequest = new TokenRequest().ttl(ttl);
            if (polices != null && !polices.isEmpty())
                tokenRequest.polices(polices);

            AuthResponse response = getDefaultConfig()
                    .auth()
                    .createToken(tokenRequest);

            return response.getAuthClientToken();
        } catch (VaultException e) {
            e.printStackTrace();
        }

        return null;
    }
}