Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Add key from file using apt-key add is not working

Due to firewall restriction, I cannot do the following command in Dockerfile:

curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -

What I did is I manually downloaded microsoft.asc, placed it and running the following in my Dockerfile

COPY myfolder/microsoft.asc /usr/
RUN apt-get update 
    && apt-get install -y curl apt-transport-https locales gnupg2 
    && /usr/microsoft.asc | apt-key add - 

This is the error I am getting:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

1: /usr/microsoft.asc: -----BEGIN: not found
2: /usr/microsoft.asc: mQENBFYxWIwBCADAKoZhZlJxGNGWzqV+1OG1xiQeoowKhssGAKvd+buXCGISZJwT: not found
3: /usr/microsoft.asc: LXZqIcIiLP7pqdcZWtE9bSc7yBY2MalDp9Liu0KekywQ6VVX1T72NPf5Ev6x6DLV: not found
4: /usr/microsoft.asc: 7aVWsCzUAF+eb7DC9fPuFLEdxmOEYoPjzrQ7cCnSV4JQxAqhU4T6OjbvRazGl3ag: not found
5: /usr/microsoft.asc: OeizPXmRljMtUUttHQZnRhtlzkmwIrUivbfFPD+fEoHJ1+uIdfOzZX8/oKHKLe2j: not found
6: /usr/microsoft.asc: H632kvsNzJFlROVvGLYAk2WRcLu+RjjggixhwiB+Mu/A8Tf4V6b+YppS44q8EvVr: not found
7: /usr/microsoft.asc: M+QvY7LNSOffSO6Slsy9oisGTdfE39nC7pVRABEBAAG0N01pY3Jvc29mdCAoUmVs: not found
8: /usr/microsoft.asc: ZWFzZSBzaWduaW5nKSA8Z3Bnc2VjdXJpdHlAbWljcm9zb2Z0LmNvbT6JATUEEwEC: not found
9: /usr/microsoft.asc: AB8FAlYxWIwCGwMGCwkIBwMCBBUCCAMDFgIBAh4BAheAAAoJEOs+lK2+EinPGpsH: not found
10: /usr/microsoft.asc: /32vKy29Hg51H9dfFJMx0/a/F+5vKeCeVqimvyTM04C+XENNuSbYZ3eRPHGHFLqe: not found
11: /usr/microsoft.asc: MNGxsfb7C7ZxEeW7J/vSzRgHxm7ZvESisUYRFq2sgkJ+HFERNrqfci45bdhmrUsy: not found
12: /usr/microsoft.asc: 7SWw9ybxdFOkuQoyKD3tBmiGfONQMlBaOMWdAsic965rvJsd5zYaZZFI1UwTkFXV: not found
13: /usr/microsoft.asc: KJt3bp3Ngn1vEYXwijGTa+FXz6GLHueJwF0I7ug34DgUkAFvAs8Hacr2DRYxL5RJ: not found
14: /usr/microsoft.asc: XdNgj4Jd2/g6T9InmWT0hASljur+dJnzNiNCkbn9KbX7J/qK1IbR8y560yRmFsU+: not found
15: /usr/microsoft.asc: NdCFTW7wY0Fb1fWJ+/KTsC4=: not found
16: /usr/microsoft.asc: =J6gs: not found
17: /usr/microsoft.asc: -----END: not found

I’m not sure if storing the file is just a bad idea, but I don’t really have other ways to go around the firewall

>Solution :

If you have the file on your file system, there’s no need to use piping to get it into apt-key add -. You can simply put the filename on the apt-key add command like this

COPY myfolder/microsoft.asc /usr/
RUN apt-get update 
    && apt-get install -y curl apt-transport-https locales gnupg2 
    && apt-key add /usr/microsoft.asc
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading