我的docker安装程序在奇怪的情况下运行
目录结构
SweetVPN/
.env
docker-compose.yml
.env
USER=myuser
PASS=mypass
docker-compose.yml
environment:
- USER=${USER}
- PASS=${PASS}
运行容器时,提示用户名和密码不正确,很明显,用户名或密码错误。
当我检查
❯ docker exec SweetVPN env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=b6dc9052d7d9
USER=rahul
PASS=mypass
问题:
user=rahul
我的主机用户是默认情况下从docker获取的主机用户吗,有什么方法可以覆盖docker-compose中的主机变量?
我在主机unset $USER
中尝试过,但是没有成功。
答案 0 :(得分:0)
您的用户 import {
HttpClient,
HttpRequest,
HttpHeaders
} from '@angular/common/http';
@Injectable()
export class HttpService {
constructor(private httpClient: HttpClient) {
}
/**
* Request options.
* @param headerOptions
* @returns {RequestOptionsArgs}
*/
private requestOptions(headerOptions?: any): any {
let options = {
headers: new HttpHeaders({
"Authorization": "Bearer " +
this.session.get('token),
"Content-Type": "application/json"
})
}
}
return options;
}
/**
* This method is use for send GET http Request to API.
* @param url - Additional request URL.
* @param body - params.
* @param options - Header(s) which will pass with particular request.
*/
get(url: string, options?: any): Observable<any> {
return this.httpClient.get(url, this.requestOptions(options))
}
/ rahul
应该在docker compose使用的Dockerfile中创建,然后替换:
mypass
作者
environment:
- USER=${USER}
- PASS=${PASS}
有关更多信息,请docker documentation