Skip to main content
added 1 character in body
Source Link
Hugo G
  • 374
  • 1
  • 10

First off, a little theory. Docker uses most of its RUN commands very similar to what git is doing with commits. That said it makes sense to put RUN commands together that change the state of the image.

By the way, just like in git you can also go back any step in Docker.

According to the Dockerfile reference on RUN the string after RUN is appended to /bin/sh -c on Linux. This means you can chain commands using the usual semicolon (;) and double ampersand (&&) operators. Example:

RUN cmake . && make && make install

Hint: The difference between the semicolon and double ampersand is that a semicolon only separates commands on one line whereas the latter will run the righthand side command only if the lefthand side is successful.

Additionally commands like apt-get install allow you to install multiple packages at once, which you actually used a few times already:

RUN apt-get install pkg1 pkg2 pkg3

If the lines get too long, you can use the backslash character (\) at the end of a line to mark a line break. Example:

RUN apt-get install pkg1 pkg2 \
pkg3 pkg4 pkg5

AnoherAnother way to optimizeoptimise the image is getting rid of the copy statements and use symlinks instead

Aside from that your Docker file looks good.

If you expect to have variations of the process anytime in the future, consider splitting it into a base image and specialized images that rely on the base.

First off, a little theory. Docker uses most of its RUN commands very similar to what git is doing with commits. That said it makes sense to put RUN commands together that change the state of the image.

By the way, just like in git you can also go back any step in Docker.

According to the Dockerfile reference on RUN the string after RUN is appended to /bin/sh -c on Linux. This means you can chain commands using the usual semicolon (;) and double ampersand (&&) operators. Example:

RUN cmake . && make && make install

Hint: The difference between the semicolon and double ampersand is that a semicolon only separates commands on one line whereas the latter will run the righthand side command only if the lefthand side is successful.

Additionally commands like apt-get install allow you to install multiple packages at once, which you actually used a few times already:

RUN apt-get install pkg1 pkg2 pkg3

If the lines get too long, you can use the backslash character (\) at the end of a line to mark a line break. Example:

RUN apt-get install pkg1 pkg2 \
pkg3 pkg4 pkg5

Anoher way to optimize the image is getting rid of the copy statements and use symlinks instead

Aside from that your Docker file looks good.

If you expect to have variations of the process anytime in the future, consider splitting it into a base image and specialized images that rely on the base.

First off, a little theory. Docker uses most of its RUN commands very similar to what git is doing with commits. That said it makes sense to put RUN commands together that change the state of the image.

By the way, just like in git you can also go back any step in Docker.

According to the Dockerfile reference on RUN the string after RUN is appended to /bin/sh -c on Linux. This means you can chain commands using the usual semicolon (;) and double ampersand (&&) operators. Example:

RUN cmake . && make && make install

Hint: The difference between the semicolon and double ampersand is that a semicolon only separates commands on one line whereas the latter will run the righthand side command only if the lefthand side is successful.

Additionally commands like apt-get install allow you to install multiple packages at once, which you actually used a few times already:

RUN apt-get install pkg1 pkg2 pkg3

If the lines get too long, you can use the backslash character (\) at the end of a line to mark a line break. Example:

RUN apt-get install pkg1 pkg2 \
pkg3 pkg4 pkg5

Another way to optimise the image is getting rid of the copy statements and use symlinks instead

Aside from that your Docker file looks good.

If you expect to have variations of the process anytime in the future, consider splitting it into a base image and specialized images that rely on the base.

First off, a little theory. Docker uses most of its RUNRUN commands very similar to what git is doing with commits. That said it makes sense to put RUNRUN commands together that change the state of the image.

By the way, just like in git you can also go back any step in Docker.

According to the Dockerfile reference on RUN the string after RUN is appended to /bin/sh -c on Linux. This means you can chain commands using the usual semicolon (;) and double ampersand (&&) operators. Example:

RUN cmake . && make && RUN make install

Hint: The difference between the semicolon and double ampersand is that a semicolon only separates commands on one line whereas the latter will run the righthand side command only if the lefthand side is successful.

Additionally commands like apt-get install allow you to install multiple packages at once, which you actually used a few times already:

RUN apt-get install pkg1 pkg2 pkg3

If the lines get too long, you can use the backslash character (\) at the end of a line to mark a line break. Example:

RUN apt-get install pkg1 pkg2 \
pkg3 pkg4 pkg5

Anoher way to optimize the image is getting rid of the copy statements and use symlinks instead

Aside from that your Docker file looks good.

If you expect to have variations of the process anytime in the future, consider splitting it into a base image and specialized images that rely on the base.

First off, a little theory. Docker uses most of its RUN commands very similar to what git is doing with commits. That said it makes sense to put RUN commands together that change the state of the image.

By the way, just like in git you can also go back any step in Docker.

According to the Dockerfile reference on RUN the string after RUN is appended to /bin/sh -c on Linux. This means you can chain commands using the usual semicolon (;) and double ampersand (&&) operators. Example:

RUN cmake . && make && RUN make install

Hint: The difference between the semicolon and double ampersand is that a semicolon only separates commands on one line whereas the latter will run the righthand side command only if the lefthand side is successful.

Additionally commands like apt-get install allow you to install multiple packages at once, which you actually used a few times already:

RUN apt-get install pkg1 pkg2 pkg3

If the lines get too long, you can use the backslash character (\) at the end of a line to mark a line break. Example:

RUN apt-get install pkg1 pkg2 \
pkg3 pkg4 pkg5

Anoher way to optimize the image is getting rid of the copy statements and use symlinks instead

Aside from that your Docker file looks good.

If you expect to have variations of the process anytime in the future, consider splitting it into a base image and specialized images that rely on the base.

First off, a little theory. Docker uses most of its RUN commands very similar to what git is doing with commits. That said it makes sense to put RUN commands together that change the state of the image.

By the way, just like in git you can also go back any step in Docker.

According to the Dockerfile reference on RUN the string after RUN is appended to /bin/sh -c on Linux. This means you can chain commands using the usual semicolon (;) and double ampersand (&&) operators. Example:

RUN cmake . && make && make install

Hint: The difference between the semicolon and double ampersand is that a semicolon only separates commands on one line whereas the latter will run the righthand side command only if the lefthand side is successful.

Additionally commands like apt-get install allow you to install multiple packages at once, which you actually used a few times already:

RUN apt-get install pkg1 pkg2 pkg3

If the lines get too long, you can use the backslash character (\) at the end of a line to mark a line break. Example:

RUN apt-get install pkg1 pkg2 \
pkg3 pkg4 pkg5

Anoher way to optimize the image is getting rid of the copy statements and use symlinks instead

Aside from that your Docker file looks good.

If you expect to have variations of the process anytime in the future, consider splitting it into a base image and specialized images that rely on the base.

Source Link
Hugo G
  • 374
  • 1
  • 10

First off, a little theory. Docker uses most of its RUN commands very similar to what git is doing with commits. That said it makes sense to put RUN commands together that change the state of the image.

By the way, just like in git you can also go back any step in Docker.

According to the Dockerfile reference on RUN the string after RUN is appended to /bin/sh -c on Linux. This means you can chain commands using the usual semicolon (;) and double ampersand (&&) operators. Example:

RUN cmake . && make && RUN make install

Hint: The difference between the semicolon and double ampersand is that a semicolon only separates commands on one line whereas the latter will run the righthand side command only if the lefthand side is successful.

Additionally commands like apt-get install allow you to install multiple packages at once, which you actually used a few times already:

RUN apt-get install pkg1 pkg2 pkg3

If the lines get too long, you can use the backslash character (\) at the end of a line to mark a line break. Example:

RUN apt-get install pkg1 pkg2 \
pkg3 pkg4 pkg5

Anoher way to optimize the image is getting rid of the copy statements and use symlinks instead

Aside from that your Docker file looks good.

If you expect to have variations of the process anytime in the future, consider splitting it into a base image and specialized images that rely on the base.