fix docker 加入集群无法正常使用问题

This commit is contained in:
bwcx_jzy 2022-06-28 19:39:33 +08:00
parent c293730543
commit 15abe8541d
No known key found for this signature in database
GPG Key ID: 5E48E9372088B9E5
3 changed files with 44 additions and 26 deletions

View File

@ -7,6 +7,7 @@
### 🐞 解决BUG、优化功能
1. 升级 SpringBoot、Hutool
2. 【server】docker 加入集群无法正常使用问题
------

View File

@ -20,17 +20,23 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
import cn.hutool.json.JSONUtil;
import com.github.dockerjava.api.DockerClient;
import com.github.dockerjava.api.command.StatsCmd;
import com.github.dockerjava.api.command.VersionCmd;
import com.github.dockerjava.api.model.Statistics;
import com.github.dockerjava.api.model.Version;
import com.github.dockerjava.core.DefaultDockerClientConfig;
import com.github.dockerjava.core.DockerClientConfig;
import com.github.dockerjava.core.DockerClientImpl;
import com.github.dockerjava.core.InvocationBuilder;
import com.github.dockerjava.httpclient5.ApacheDockerHttpClient;
import com.github.dockerjava.transport.DockerHttpClient;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.LoggerFactory;
@ -41,8 +47,8 @@ import org.slf4j.LoggerFactory;
public class TestLocal {
private DockerClient dockerClient;
@Test
public void test() {
@Before
public void init() {
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
Logger logger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
logger.setLevel(Level.INFO);
@ -60,10 +66,22 @@ public class TestLocal {
// .responseTimeout(Duration.ofSeconds(45))
.build();
this.dockerClient = DockerClientImpl.getInstance(config, httpClient);
}
@Test
public void test() {
dockerClient.pingCmd().exec();
VersionCmd versionCmd = dockerClient.versionCmd();
Version exec = versionCmd.exec();
System.out.println(exec);
}
@Test
public void tset2() throws InterruptedException {
StatsCmd statsCmd = dockerClient.statsCmd("5848fd613ea41f9b370a26949f590be107c165872bfc007f666b26d8a2247ac2");
Statistics statistics = statsCmd.exec(new InvocationBuilder.AsyncResultCallback<>()).awaitResult();
System.out.println(statistics);
System.out.println(JSONUtil.toJsonStr(statistics));
}
}

View File

@ -183,12 +183,11 @@
option-filter-prop="children"
@change="
(v) => {
if (
swarmList.filter((item) => {
tempList = swarmList.filter((item) => {
return item.id === v;
}).length
) {
temp = { ...temp, remoteAddr: temp[0].nodeAddr };
});
if (tempList.length) {
temp = { ...temp, remoteAddr: tempList[0].nodeAddr };
} else {
temp = { ...temp, remoteAddr: '' };
}