&quot&quot" head \ https://registry-1.docker.io/v2/testcontainers/ryuk/manifests/0.3.0 \:noverizatiand \:nocratorized:不正确的用户名或密码;运行测试时
我在Spring Boot应用程序中添加了TestContainer,
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@SpringBootTest
@Testcontainers
@AutoConfigureMockMvc
class ProductServiceApplicationTests {
@Container
static MongoDBContainer mongoDBContainer = new MongoDBContainer("mongo:4.4.2");
@Autowired
private MockMvc mockMvc;
@Autowired
private ObjectMapper objectMapper;
@DynamicPropertySource
static void setProperties(DynamicPropertyRegistry dynamicPropertyRegistry) {
dynamicPropertyRegistry.add("spring.data.mongodb.uri",mongoDBContainer::getReplicaSetUrl);
}
@Test
void shouldCreateProduct() throws Exception {
ProductRequest productRequest = getProductRequest();
String productRequestString = objectMapper.writeValueAsString(productRequest);
mockMvc.perform(MockMvcRequestBuilders.post("/api/product")
.contentType(MediaType.APPLICATION_JSON)
.content(productRequestString)
).andExpect(status().isCreated()) ;
}
private ProductRequest getProductRequest() {
return ProductRequest.builder()
.name("Iphone 13")
.description("Iphone 13")
.price(BigDecimal.valueOf(1200))
.build();
}
}
- 我已经安装了Docker桌面并使用Docker桌面记录了它,然后尝试使用CLI。
运行时 获取以下错误
com.github.dockerjava.api.exception.internalserervererrorexception:状态500:{“ message”:“ head” https://registry-1.docker.io/v2/testcontainers/testcontainers/ryifests/ryifests/manifests/0.3.0.0.3.0.3.0.3.0.3.0.3.0 “:未经授权:不正确的用户名或密码”} atrg.testcontainers.shaded.com.github.dockerjava.core.defaultinvocationbuilder.execute(defaultinvocationbuilder.java:247) 请访问org.testcontainers.shaded.com.github.dockerjava.core.defaultinvocationbuilder.lambda $ executeandstream $ 1(defaultinvocationbuilder.java:269) 在java.lang.thread.run(thread.java:748) 中
I have added testcontainer in spring boot app
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@SpringBootTest
@Testcontainers
@AutoConfigureMockMvc
class ProductServiceApplicationTests {
@Container
static MongoDBContainer mongoDBContainer = new MongoDBContainer("mongo:4.4.2");
@Autowired
private MockMvc mockMvc;
@Autowired
private ObjectMapper objectMapper;
@DynamicPropertySource
static void setProperties(DynamicPropertyRegistry dynamicPropertyRegistry) {
dynamicPropertyRegistry.add("spring.data.mongodb.uri",mongoDBContainer::getReplicaSetUrl);
}
@Test
void shouldCreateProduct() throws Exception {
ProductRequest productRequest = getProductRequest();
String productRequestString = objectMapper.writeValueAsString(productRequest);
mockMvc.perform(MockMvcRequestBuilders.post("/api/product")
.contentType(MediaType.APPLICATION_JSON)
.content(productRequestString)
).andExpect(status().isCreated()) ;
}
private ProductRequest getProductRequest() {
return ProductRequest.builder()
.name("Iphone 13")
.description("Iphone 13")
.price(BigDecimal.valueOf(1200))
.build();
}
}
- I have installed docker desktop and logged it using docker desktop And then try using cli.
When Running it
Getting the below error
com.github.dockerjava.api.exception.InternalServerErrorException: Status 500: {"message":"Head "https://registry-1.docker.io/v2/testcontainers/ryuk/manifests/0.3.0": unauthorized: incorrect username or password"}
at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.execute(DefaultInvocationBuilder.java:247)
at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.lambda$executeAndStream$1(DefaultInvocationBuilder.java:269)
at java.lang.Thread.run(Thread.java:748)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这对我有帮助:
在这里找到它 - htttps:htttps:// forums.docker.com/t/unauthorized-incorrect-username-orname-orname-or-password/35677/4
This helped me:
Found it here - https://forums.docker.com/t/unauthorized-incorrect-username-or-password/35677/4
netcfg -d
,然后重新启动您的PC。这对我有用
参考
https://github.com/github.com/testcontcontainers/testcontcontcontcontcontcontcontcontcontcontcontcontcontcontcontainers-java/sissues/3422
netcfg -d
in Command Prompt then restart your PC.This worked for me
Reference
https://github.com/testcontainers/testcontainers-java/issues/3422
在M1 Mac上对我有用的修复程序是:
credsstore:desktop
from〜/.docker/config.jsondocker login
in终端中The fix that worked for me on an M1 Mac was:
credsStore:desktop
from ~/.docker/config.jsondocker login
in terminal以下解决方案在Win11上对我有用:
Docker登录Index.docker.io
The following solution worked for me on Win11:
docker login index.docker.io