Skip to content

Commit

Permalink
[docker_img_ctl.j2] make tmpfs mounts optional and add ability to run…
Browse files Browse the repository at this point in the history
… container by image id (sonic-net#6439)

- Why I did it
I made the docker_img_ctl.j2 applicable for more dockers (including application extensions dockers) by adding an option not to mount tmpfs on /tmp/ and /var/tmp/. In some applications /tmp/ is a different docker volume which can't be tmpfs.
Also, I added and ability to pass REPO[:TAG]|[@digest]/IMAGE_ID instead of just REPO name.

- How I did it
Modified docker_img_ctl.j2 and docker makefiles.

- How to verify it
Run it on the switch.
  • Loading branch information
stepanblyschak authored and Carl Keene committed Aug 7, 2021
1 parent e709169 commit 3eb5323
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
16 changes: 14 additions & 2 deletions files/build_templates/docker_image_ctl.j2
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function updateSyslogConf()
{
# On multiNPU platforms, change the syslog target ip to docker0 ip to allow logs from containers
# running on the namespace to reach the rsyslog service running on the host
# Also update the container name
# Also update the container name
if [[ ($NUM_ASIC -gt 1) ]]; then
TARGET_IP=$(docker network inspect bridge --format={{ "'{{(index .IPAM.Config 0).Gateway}}'" }})
CONTAINER_NAME="$DOCKERNAME"
Expand Down Expand Up @@ -380,9 +380,11 @@ start() {
-e SX_API_SOCKET_FILE=/var/run/sx_sdk/sx_api.sock \
-v /dev/shm:/dev/shm:rw \
{%- else %}
{%- if mount_default_tmpfs|default("n") == "y" %}
--tmpfs /tmp \
{%- endif %}
{%- endif %}
{%- endif %}
{%- if sonic_asic_platform == "broadcom" %}
{%- if docker_container_name == "syncd" %}
-v /var/run/docker-syncd$DEV:/var/run/sswsyncd \
Expand All @@ -404,13 +406,23 @@ start() {
$REDIS_MNT \
-v /usr/share/sonic/device/$PLATFORM:/usr/share/sonic/platform:ro \
{%- if sonic_asic_platform != "mellanox" %}
{%- if mount_default_tmpfs|default("n") == "y" %}
--tmpfs /tmp \
{%- endif %}
{%- endif %}
{%- if mount_default_tmpfs|default("n") == "y" %}
--tmpfs /var/tmp \
{%- endif %}
--env "NAMESPACE_ID"="$DEV" \
--env "NAMESPACE_PREFIX"="$NAMESPACE_PREFIX" \
--env "NAMESPACE_COUNT"=$NUM_ASIC \
--name=$DOCKERNAME {{docker_image_name}}:latest || {
--name=$DOCKERNAME \
{%- if docker_image_name is defined %}
{{docker_image_name}}:latest \
{%- else %}
{{docker_image_id}} \
{%- endif %}
|| {
echo "Failed to docker run" >&1
exit 4
}
Expand Down
1 change: 1 addition & 0 deletions slave.mk
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
export docker_image="$(docker)"
export docker_image_name="$(basename $(docker))"
export docker_container_name="$($(docker:-dbg.gz=.gz)_CONTAINER_NAME)"
export mount_default_tmpfs="y"
$(eval $(docker:-dbg.gz=.gz)_RUN_OPT += $($(docker:-dbg.gz=.gz)_$($*_IMAGE_TYPE)_RUN_OPT))
export docker_image_run_opt="$($(docker:-dbg.gz=.gz)_RUN_OPT)"

Expand Down

0 comments on commit 3eb5323

Please sign in to comment.